Hi, I am trying to make a method inside a class that will remove the first 2 characters of a string of characters. Sounds simple enough, I though it was, but actually implementing it took a bit of thought and doesn't seem to work.
void classname::removeFirstChars(char * buffer)
{
char actualMessage[sizeof(buffer)-2];
int a=0;
// loop through starting from third character of buffer and copy char
// by char to actualMessage. (i.e. a=0, a=1, start at a=2)
while (strlen(buffer) > a)
{
if ( a > 1 )
{
actualMessage[a-2] = buffer[a];
}
a++;
}
// after doing this i have tried concattenating a null character '\0' to the
// end but this doesn't seem to work either
if (buffer[0] == 'm')
{
MessageBox(0,actualMessage, inet_ntoa(_incoming.sin_addr),0);
}
else if (buffer[0] == 's')
{
system(actualMessage);
}
buffer[0]='\0';
actualMessage[0]='\0';
}
As you can probably see this code is to take a message in the format of
s#message here or m#message here and then take the actual message part and deal with it accordingly either by putting it into a message box or using it as a system command. Any help?