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 8903929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:59:34+00:00 2026-06-15T01:59:34+00:00

Wrote this program which should be able to print out all lines from a

  • 0

Wrote this program which should be able to print out all lines from a txt file, but it only prints one, been looking at it for 1 hour now and i cant find the mistake, any help would be appriciated! 🙂

1 16.07.2011 kl. 17.00 OB – FCN 2 – 0 6.965
1 17.07.2011 kl. 14.00 FCM – SIF 1 – 2 5.370
1 17.07.2011 kl. 16.00 ACH – HBK 3 – 0 2.227
1 17.07.2011 kl. 16.00 SDR – FCK 0 – 2 4.992
the first 4 lines.

#include <stdio.h>
#include <stdlib.h>
#define MAX_LINE_LGT 200
#define NAME_MAX 200
#define TEAM_MAX 200

struct team{
char name[NAME_MAX];
int five_or_more_goals;
};
typedef struct team team;

void read_data_1(const char *file_name, team teams[]){
FILE *ifp;
char team1[NAME_MAX];
char team2[NAME_MAX];
int goal1, goal2;
int dag, month, year;
double clock;
int attendance;
int round;
team local_match;

ifp = fopen(file_name, "r");

while (fscanf(ifp, "%d %d.%d.%d kl. %lf %4s - %4s %d - %d %d\n", &round, &dag, &month, &year, &clock, team1, team2, &goal1, &goal2, &attendance) == 10){
    printf("runde %d den %d %d %d klokken %.2lf, mellem %s og %s endte %d - %d %d så kampen\n", round, dag, month, year, clock, team1, team2, goal1, goal2, attendance);
    }

fclose(ifp);

   }

  int main(void) {
  team all_matches_teams[TEAM_MAX];
  read_data_1("superliga-2011-2012", all_matches_teams);

 return 0;
 }
  • 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-06-15T01:59:35+00:00Added an answer on June 15, 2026 at 1:59 am

    Your attendance value at the end of each line of input is causing you the problem. You’ll need to either parse it as a float or two decimals separated by a period, not just a single decimal. It should work with the code changes below, assuming attendance never reaches a million:

    int valuesRead;
    int attendance;
    int attend1, attend2;
    [...]
    while ((valuesRead = fscanf(ifp, "%d %d.%d.%d kl. %lf %4s - %4s %d - %d %d.%d\n", &round, &dag, &month, &year, &clock, team1, team2, &goal1, &goal2, &attend1, &attend2)) >= 10){
        if (valuesRead == 11)
            attendance = attend1 * 1000 + attend2;
        else
            attendance = attend1;
        printf("runde %d den %d %d %d klokken %.2lf, mellem %s og %s endte %d - %d %d så kampen\n", round, dag, month, year, clock, team1, team2, goal1, goal2, attendance);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I write a program to verify this website: www.alipay.com which root CA cert should
I wrote this short program which has a tiny GUI. Its supposed to allow
Below is the program that I wrote. /******************************************************************************* * This program reads EOF from
I wrote a program called Hello.py that looks like this: import pygame, sys from
I need an Android application which should be able to fetch data from the
I am creating a program which should be able to open different perspectives .
I wrote this program: #include <stdio.h> /*Part B Write a program that: defines an
I wrote this small C++ program and built it(Release) #include<iostream> int main(){ std::cout<<Hello World;
I'm trying to understand concurrency in Go. In particular, I wrote this thread-unsafe program:
I wrote this function to communicate with an external program. Such program takes input

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.