Results 1 to 2 of 2

Thread: how to trim weird character?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2005
    Posts
    228

    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 ?
    effort effort effort and still effort

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: how to trim weird character?

    You could try IsWhiteSpace (a static method of char class) instead of hardcoding tabs and spaces.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width