1 Replies - 177 Views - Last Post: 05 May 2019 - 11:19 AM Rate Topic: -----

#1 TheRedHat   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-December 18

Reading files with special format

Posted 05 May 2019 - 09:04 AM

Hello guys.
I have a text file with content:

ST001
Andrew Johnson
4 5 6
ST002
Peter Ohlander
8 7 9

I want to write content of this file to a structure:

<code>
struct student
{
    char id[10];
    char name[50];
    double math_score;
    double physics_score;
    double chemistry_score;
};

:code:
How to do it using file operation in C ? I/ve tried many solutions, but always stuck in reading score to structure field.
</code>

This post has been edited by modi123_1: 05 May 2019 - 09:38 AM
Reason for edit:: In the future please use the [code] tag button in the editor


Is This A Good Question/Topic? 0
  • +

Replies To: Reading files with special format

#2 jimblumberg   User is offline

  • member icon

Reputation: 5732
  • View blog
  • Posts: 17,558
  • Joined: 25-December 09

Re: Reading files with special format

Posted 05 May 2019 - 11:19 AM

Quote

How to do it using file operation in C ? I/ve tried many solutions, but always stuck in reading score to structure field.


Show us what you tried then perhaps someone can help you figure out what is wrong.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1