I am trying to process text received from a fstream getline. I know C well ( and probably have all its bad habits ) but am just learning C++.
I basically want to get a line of text from a file and then remove the space characters so that the array consists of only relevant characters with the final character being a termination character..
For some reason, the while loop gets iterating and does not find the '\0' which I understand the getline function adds...
Any help would be greatly appreciated!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void getFinalStates(void) {
int i=0;
int j=0;
char linebuffer[256];
char finalstates[256];
file.getline(linebuffer,'\n');
while (linebuffer[i] != '\0')
if (linebuffer[i]!= ' ') finalstates[j++] = linebuffer[i++];
return;
}