My idea is to read the file with getLine() method (which will result a very long string), split it with string tokenizer with space delimiter(I did not find a method to do this automatically like StringTokenizer in Java) and covert it one by one to integer and put it into an array.
I find this method is very exhaustive. Any best practice for this problem? Can I read the file delimited with space instead of per line? Any tokenizer method without doing it manually?
AnswerBot
Question subject: Re: Reading file with integers
Posted: Sat Nov 08, 2008 10:54 pm
Joined: Sun Oct 19, 2008 3:53 pm Posts: 229 Has thanked: 0 time Have thanks: 0 time
Call fscanf() in a loop until you are done reading all the integers. Use %d as the format string.