Reading punctuation as spaces.

This segment is supposed to read in a single word and is working properly with one minor failure. when punctuation is introduced instead of ignoring it is reading it in as a blank space.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
in_file.get(ch);
 	
while(isalpha(ch))
{
	if(i > MAX-1)
	    in_file.get(ch);
	else
	{
	    ch = tolower(ch);
	    word[i] = ch;
	    i++;
	}

    in_file.get(ch);

}
It looks like it would read the punctuation and then break out of the while loop. It would not be stored in word but the value if i is at were it would have been. So, are you looking at the value of word[i]? Because that has not been assigned.
Topic archived. No new replies allowed.