I want to delete white space in a file without using isspace or skipws.
Code so far:
char next_symbol;
while (in_stream)
{
in_stream.get(next_symbol);
putchar (toupper(next_symbol));
}
So I think I need to add in the brackets " if (next_symbol == ' ') then cout << something that would remove that white space. I would need to leave one white space between each word though. Any ideas how to code this?
Thanks Pan, that is a bit too advanced for me where I am currently holding in class. I was thinking more along the lines of: if (next_symbol == ' ') cout << '\b';
Problem is, this deletes all white spaces and text is unreadable. What I would like to do is if (next_symbol == ' ') and then use && to ask if the next "next_symbol" is also a space (' '), if this is True then it should delete the spaces. Otherwise it will just cout the "next_symbol"
Use a simple state machine. Keep a boolean variable that is set to true if the last character read was a space or
false otherwise. Then, when you read a space, you output it only if the variable is false.