Hello,

I have to read a file, line by line, and do different things depending on what's in each line.

The input consists of one command, some arguments (0, 1 or 2) and comments (everything after a # is a comment). It would be something like this:

Code:
addUser 0 John
addUser 1 Peter
printUsers
remove user 0 #removes John
#now there's only one user
addUser 0 John
#John is back!
My approach would be reading char by char (with getchar), until I find a space, and store this in an array of chars (char command[100], for example), and do the same for the arguments. If I find a '#', then I'd just do getchar until I find a '\n'.

I also thought about using scanf and fgets, but I thought it'd be more complex to implement.

I'd appreciate if I could hear opinions on the best approach. Thanks.