• ### Popular Now

• 13
• 18
• 19
• 27
• 10

#### Archived

This topic is now archived and is closed to further replies.

# file i/o

This topic is 5987 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

If have a textfile which looks like this: ; lengt 1000 ; start 0 ; jump 100 700.000 3 100.000 4 Now i open the file with fopen and then i want to pass the lines with a ; and go to the numbers below and read them one by one and store them in a buffer. How can this be done. How can a pass all the lines with a ; and read those numbers until i find an end of file? Thanx in advance

##### Share on other sites
Read the file a line at a time, and any line that begins with a '';'' skip. Kind of like this:
  /* Assumes less than 512 on each line for simplicity*/char Buffer[512];FILE *File = fopen(...);/* ... */for( ; ; ) { if(fgets(Buffer,512,File) == NULL) break; switch(Buffer[0]) { case '';'': break; default: /* Get Number from Buffer with atof or sscanf */ break; }}fclose(File);

[Resist Windows XP''s Invasive Production Activation Technology!]

##### Share on other sites
But how about the points in the file. Does the computer see that as thousands or as a decimal divider?? And i want the numbers to be written in an array of characters and then send them over. but how do i recognize the different numbers in an array of characters because they do not fit in one memory location of the array?

ANYONE??