I'm following Bjarnes book practices and principles chapter 11 page 400, here we are creating a punct stream which basically parses a sentence to eliminate any punctuation. the code is practically a mirror image to the code wrote in the book
but for some reason the while loop never ends, I'm not entirely sure why, I would expect for the stringstream buffers eof() to be set to true eventually but it seems like this never happens, also same thing with source I would expect to eventually hit and eof no?
**edit the buffers eof does indeed get set to true I just moved the test for eof out of the while loop, but this still didn't fix the problem the program is stuck in an infinite loop
The code seems overly complicated. Your main loop is while (ps >> word). How exactly do you want the stream loop to end?
It's prompting you for data. I can make it end by pressing Ctrl + Z and Enter in windows. Otherwise, why would it not be an infinite loop? You need std::cin (your "source") to be in a bad state for it to fail and stop looping.
If you pipe stuff into the program instead of running the program directly, it will also not go into any infinite-prompting loop.
e.g. >echo 1 2 3 4 5 | program_name