Here is a sample input that I have:(each char is separated by a \t)
1 1 0 0 A
Now my code breaks it up into tokens when it looks like, but what I want it to do is to break it up into and recognize blank, or empty. Something like this:
1 1 A
My code will print this for the first sample:
1
1
0
0
A
And this for the second sample:
1
1
A
What I want it to do is to print 0s for any blank/empty positions:
I agree. Please don't use strtok() in C++ programs. (The function is evil to begin with.)
There was a recent Article on it: http://www.cplusplus.com/forum/articles/4860/
(Be aware that my example in this article does not account for empty fields --the same as strtok().)
You can also use getline() and a stringstream:
(This example does account for empty fields.)