If you want to lex a file, the easiest way is to read it character by character and building up the tokens yourself.
This way you get full control of what is going on.
If you want more specific help you need to give a more specific explanation of your problem
You don't have to tokenize because your tokens are all the same (strings with no meaning). Just ignore whitespace. You can take advantage of operator >>:
You can only pass that method one character to be a delimiter, so I don't see how you can ignore either ' ' or '\n' in a single call. You could use strtok() ( http://www.cplusplus.com/reference/clibrary/cstring/strtok/ ), which takes a string of delimiters and works much like you requested.