I have a file of numbers that looks like this;
003 334 556 283 294 102 586 294 ...
Each 3 digit number is separated by space, on one line.
What I would like, is to be able to read a number, digit by digit, until it hits a space, then move the cursor again (so the space is overcome) and restart the loop with the next number. Each digit would be assigned to an index within an array. This array would be overwritten on the next loop - which is fine.
E.g. 003
The cursor starts at the start of the file. Reads 0, assigns to array[0], reads 0, assigns to array[1], reads 3, assigns to array[2], reads space, does some other stuff, then starts the loop again.
Does the cursor reading the file know when it has hit a space? Is there a way to use this to restart my loop? I understand using feof
for the end of the file, is there something similar for whitespace?
I have more to do once the digits are all read into the array, that's why I would like them in that format. Once I have finished with that number of 3 digits, I want to move onto and do the same with the next and so on.
I hope this makes sense!
I couldn't find anything to help me, hence why I've asked on here. Obviously, if there is an answer already written, point me in that direction!