file io - C - regarding the EOF function -


i trying mess around file input in c, integer values in matrix format. instance, if have file like...

4 5 7 3 6 8 5 2 5 7 3 4 9 4 8 7 

i confused eof command do. know can use check end of file, if wanted test end of row? if wanted print diagonal right left ( 3,5,7,9 ). know have go row row, set counter counts @ each iteration find length of rows, print out last value of row, deduct pointer 1 , go onto next row. how can this? in, eof file whole, or there c command can more directly define row lengths , such.

a typical c program reads multiple lines this:

char line[max_line_size]; while (fgets(line, sizeof(line), inputfile) != null) {     /* line */ } 

the part says "do line" should something. 1 thing in case parse line, , 1 of numbers in it. 1 depend on line number (which have keep track of self), first number first line, second number second line, etc. when have numbers (i.e. when loop ends) want data.

after loop ends, can use feof or ferror see if ended because of end-of-file or error.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -