how to trim weird character?
I am using Visual studio 2005.
i have a file that I have to read in. the text inside the file is something like this
Code:
Program
start
integer a, b, ba=0, xx[10];
I used getline (inStream, dump[i], ' ') to read the line and dump it into dump[i].
when I reached the second line it reads the whole line, from "start" until "integer". I tried to eliminate the whitespace and the tab between those 2 words. When I trim it i do it like this
Code:
string abc;
int pos(token[i].size());
abc= token[i].c_str();
for (int m = 0 ; m < pos; m++ ){
if (abc[m] == ' ' || abc[m]=='\n' || abc == '\t')
{
abc.erase(m, 1);
}
it does not produce the result that I desire. I use debugger to check it, when it encounters the whitespace, the if statement does not trap that for some reason. anybody can tell me what character is that and how to eliminate it ?
Re: how to trim weird character?
You could try IsWhiteSpace (a static method of char class) instead of hardcoding tabs and spaces.