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

  • Home
  • SEARCH
  • 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 7688231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:52:21+00:00 2026-05-31T19:52:21+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]);
//void calcData(SKATER skater[MAX]);


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

    // Function calls
    num = getData(skater);
    //calcData(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, 100, fpIn))
    {
        sscanf(buffer,"%*c%19[^0123456789]", skater[i].name);   
        puts(buffer);
        for(k = 0; k < MAX_BASE; k++)
        {
           sscanf(buffer,"%d %f", &skater[i].elements, skater[i].baseval);
           for(j = 0; j < COLUMN_SCORE; j++)
            {
                sscanf(buffer,"%d", &skater[i].score[k][j]);                
            }
        } 

        i++;
    }
        system("PAUSE");
    fclose(fpIn);
    return i;
}

This getdata function is to read the data from a file to arrays of structure.The first line contain the name, the next line contain the elements number the base value and the rest of of the numbers is the score, this gets repeat 8 time. The getdata function only read the first 3 line of data include the name 2 other line when i try puts(buffer) why do i get this problem can anyone tell me how to fix it ? Am i having any logical error?

this is the data :

MENS SHORT PROGRAM//http://www.isufs.org/results/owg2006/OWG06_Men_SP_Scores.pdf
LYSACEK Evan 
1  7.5 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3
2 10.0 1 2 2 1 1 1 1 2 0 1 1 1
3 3.0 1 2 2 2 1 0 1 2 1 1 1 2
4 3.1 1 1 1 1 1 0 0 0 1 0 1 0
5 1.7-3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3
6 2.1 0 0 1 1 1 1 1 1 1 1 1 1
7 3.1 0 0 1 1 0 0 1 1 1 1 1 1
8 3.5 0 1 1 2 1 1 1 1 1 1 0 1
WEIR Johnny
1 7.5 2 2 2 2 1 1 1 1 1 2 1 1
2 10.0 1 1 1 1 2 0 1 1 1 1 2 1
3 3.0 1 1 1 2 1 0 1 1 2 2 2 2
4 3.1 1 2 1 2 1 1 0 0 2 1 1 0
5 5.5 0 -1 0 -1 -1 0 -1 -1 1 -2 -2 -2
6 1.3 1 1 1 2 1 1 1 0 1 1 1 2
7 3.1 0 1 1 1 1 0 0 1 2 1 1 1
8 3.0 -1 1 1 2 1 0 1 0 2 1 -1 1
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
SAVOIE Matthew 
1 3.0 0 0 0 1 0 0 0 0 0 0 0 -1
2 7.5 1 2 2 1 1 1 1 1 1 1 2 2
3 9.5 0 1 1 0 0 0 0 0 0 0 1 1
4 3.1 1 1 1 1 1 1 0 0 1 1 0 0
5 1.9  -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3 -3
6 2.1 0 0 1 0 1 0 0 1 1 1 1 1
7 3.1 0 0 1 0 0 0 1 1 2 0 2 1 
8 3.0 0 0 1 1 1 0 1 1 1 1 1 1
  • 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-31T19:52:23+00:00Added an answer on May 31, 2026 at 7:52 pm

    Since it is homework I will only give you some hints on what you have going wrong. I hope this gets you back on the right track! 🙂

    1. You mention that you are only reading in a limited number of lines. You should look to your loop condition, “while(i < MAX_SKATER && fgets(“, to see why it is only printing a few of your lines.

    2. I will give you this one since you are just starting. In your sscanf call to read in the score line, every parameter must be passed as a pointer. The second variable you pass in to receive data isn’t being passed correctly. Instead use “&skater[i].baseval”. The same goes for your player name sscanf.

    3. You will need to call fgets again, likely in your “for(k” loop. As you have it, you are only attempting to read in your header line. Then you are re-using the same buffer data (a header line) when trying to parse a score line.

    4. You will need to separate your sscanf in your “for(j” loop, resulting in a new sscanf in your “for(k” loop. You will have to read in the player number and baseval separate from the scores because you have a variable number of scores to read (COLUMN_SCORE).

    • 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
#include <stdio.h> #include <stdlib.h> #define MAX 21 #define MAX_ELEM 8 #define SCORE 12 #define
I have the following code: #include <stdlib.h> #include <stdio.h> #include <pthread.h> #define NUM_THREADS 100

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.