If I am reading input from a file such as
How do I get my program to register each number as separate input?Code:1 2 3 4 5
Thanks
If I am reading input from a file such as
How do I get my program to register each number as separate input?Code:1 2 3 4 5
Thanks
Look at scanf. When used with most* format specifiers, it will stop at or skip over white space (space, tab, newline). This works well for files like yours, with numbers. Use "%d" for integers, "%f" for floats and "%lf" for doubles. There are lots more options, but those should cover 90% of your cases. scanf is great for well formatted files, but can be a pain for user input or files where typos are common.
* I say most. The behavior for reading characters (using "%c") is different, and the behavior for reading strings strings (using "%s") may be undesirable, i.e. you can't read multi-word strings.
an alternative to scanf is to read a whole line with fgets and then separate the inputs with strtok.