This is a snippet of my code that does not work:
I use a text file with 3 words "this this this". The string word records the letters that are found but when it gets to the spacebar, with ascii code 32, instead prints -1 and the "y with dots over it symbol" goes into the string.
How should I fix this?
Code:
while(ascii != 32) // while character is not space
{
letter = (char) infile.get(); //retreive next character
ascii = (int) letter;
if (ascii == 32)
break;
word = word + letter;
}
How should I fix this?
Comment