tags:

views:

100

answers:

2

Hi,

ist is possible? What would be the easiest way? I tried to compare in the input string character to character so

if(char([i]=="^M") char[i]=""

but it does not work.

By the way, if I were able to check it, what is the wistes substitution? to "" ?

Thanks

+2  A: 

A control-M isn't stored as a multiple key sequence in a text file. It's generally stored as the ascii value 13, or 0x0d in hexadecimal.

So, your statement would be:

if (char[i] == 0x0d)

or

if (char[i] == '\x0d')

Kluge
A: 

If you have a mutable array of char then if you need to remove a given character you'll need to move all the characters after the removed character up one place, not just assign a 'blank' to the given character.

It's probably easiest to do this with pointers.

E.g. (in place transformation):

extern char *in;
char *out = in;

while (*in)
{
    if (*in != '\r')
        *out++ = *in;

    in++;
}

*out = '\0';
Charles Bailey
Haha, look at all those blue identifiers in your code!
Blindy