Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7658389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:43+00:00 2026-05-31T13:11:43+00:00

#include <stdio.h> #include <stdlib.h> #define MAX 20 #define MAX_BASE 8 #define ROW 9 #define

  • 0
#include <stdio.h>
#include <stdlib.h>

#define MAX 20
#define MAX_BASE 8
#define ROW 9
#define COLUMN_SCORE 12
#define MAX_SKATER 4

typedef struct{
            char  name[MAX];
            int   elements;
            float baseval[MAX_BASE];
            int score[12][MAX_BASE];
            double total_score;
          }SKATER;

int getData(SKATER skater[MAX]);


int main (void)
{
    // Global Declarations
    SKATER skater[MAX_SKATER];
    int num;

    // Function calls
    num = getData(skater);

return 0;
}

/********************************* getData ************************************
Pre:
Post:
*/
int getData(SKATER skater[MAX_SKATER])
{
    // LOcal Declarations
    FILE* fpIn;
    int   i = 0;  
    int   k;
    int   j;
    char  buffer[100]; 

    // Statements
    if((fpIn = fopen("lab6data.txt","r"))==NULL)
    {
    printf("File opening error");
    system("PAUSE");
    exit(100);
    }

    while(i < MAX_SKATER && fgets(buffer, sizeof(buffer) - 1, fpIn))
    {
         sscanf(buffer,"%*c%19[^0123456789]%[^\n]", skater[i].name);    
         for(k = 0; k < MAX_BASE; k++)
             printf("loop");
             sscanf(buffer,"%d", &skater[i].elements, skater[i].baseval);
             for(j = 0; j < COLUMN_SCORE; j++)
             {
                sscanf(buffer,"%d", skater[i].score[k][j]);
             }
        i++;        
    }

    fclose(fpIn);
    return i;
}

Hi, When I tried to debug this code it shows me the error that buffer was overrun, how do I fix this error? This is the first time that I’ve encounter this error, also, I’m not sure if the way that I approach this problem was right? can anyone tell me a way to approach the problem
so here is the sample data for the problem:

PLUSHENKO Evgeni
1 13.0 0 2 1 1 1 0 1 0 1 1 1 1 
2 7.5 1 2 2 2 2 1 2 1 2 2 2 2
3 6.0 2 1 1 1 1 0 0 2 1 2 1 2
4 2.3 2 1 1 1 1 1 2 1 1 1 1 1
5 3.4 2 2 2 2 1 2 3 3 2 3 2 1
6 2.1 1 1 1 2 2 0 0 0 1 2 1 1
7 3.1 1 0 2 2 1 1 1 2 2 2 2 1
8 3.5 1 1 2 2 1 1 1 1 2 2 1 1  

There are 3 more blocks of data beside this one
thank for helping

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:11:43+00:00Added an answer on May 31, 2026 at 1:11 pm

    You define int score[12][MAX_BASE]; in the struct SKATER.But you scanf like this:

             for(j = 0; j < 12; j++)
             {
                sscanf(buffer,"%d", skater[i].score[k][j]);
             }
    

    The index is error.You should change to sscanf(buffer,"%d", &skater[i].score[j][k]); and don’t miss &

    sscanf(buffer,"%d", &skater[i].elements, skater[i].baseval); change to sscanf(buffer,"%d %f", &skater[i].elements, skater[i].baseval);

    I think you need read this.Need passed the point to sscanf

    Good Luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#include <stdio.h> #include <stdlib.h> #define MAX 20 #define MAX_BASE 8 #define ROW 9 #define
#include<stdio.h> #include<iostream.h> #include<conio.h> #include<stdlib.h>(TOP) #include<fstream.h> #define MAX 5 int top = -1; int stack_arr[MAX];
#include<stdio.h> #include<stdlib.h> #define n ((sizeof(char)) * 100 ) int stringlength(char * str) { int
#include<stdio.h> #include<stdlib.h> #define MAX 1000 struct island{ double left; //gobal double right; } island[MAX];
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { // int char str[40],ch; FILE*fp,*fp1,*fp2; fp=fopen(ide_input,w); fp1=fopen(error_log,w); fp2=fopen(lex_output,w);
#include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char
#include stdio.h #include conio.h #include stdlib.h #define RANGE(i, min, max) (i<min) || (i>max) ?
#include <stdio.h> #include <stdlib.h> #define calc(a,b) (a*b)/(a-b) void calculate(){ int a = 20, b
I have the following code: #include <stdlib.h> #include <stdio.h> #include <pthread.h> #define NUM_THREADS 100
#include <stdio.h> #include <stdlib.h> #include <time.h> void initDeck (int deck[]); void showDeck (int deck[]);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.