Hi, I'm writing a program that separates strings. It needs to separate a string first by pipes ("|") and then by spaces. After the do-while loop which generates tokens delimited by pipes, the cout statement doesn't execute, but the system sleep statement does! I can't figure out why cout no longer works.
The program has to break down a command such as "ps -aux | more", so I am trying to get tokens delimited by pipes first. Later, I will use spaces as the delimiter to get "ps" and "-aux" (this is what the firstpart is going to be used for).
Thanks for the input on the while loop. I've changed that, since the do-while allowed a cout << NULL on its final pass.
Thanks for looking into line 26. I'm still baffled at how it can execute line 27 and not 26. It makes me think there is something wrong with cout, even though the buffer is flushed. The program is just terminating as if nothing is wrong.
Even with a normal while loop, there was still a cout << NULL happening. This causes undefined behavior and prevents further cout << statements from functioning. I fixed it by writing the loop this way (I didn't know you could have an assignment occur inside the conditional):