i've been trying to use fscanf to parse parts of a line from a file. The format of each line is like the following:
Connecticut,1788,Hartford,29
I've been trying to use this:
fscanf( fpIn, "%[^,], %d% [^,], %d", name, &year, cap, &popRank )
To extract the state, year, capital, and population rank into the respective fields but it only reads the first two.
And, correct me if i'm wrong, but the the [^,] operation reads everything up to a comma right? According to some of the code snippets i read around here, i'm supposed to place a comma after [^,] but i'm not understanding why I would need to do that.
Thanks for any help you guys could give.