Hi I would like to create a function that appends a character to a character array.. this is what I have got so far..
char * appendCharToCharArray(char * array, char a)
{
char * ret = (char*)malloc(sizeof(array) + 1 + 1);
strcpy(ret,array);
ret[strlen(ret)] = a;
ret[sizeof(ret)] = '\0';
return ret;
}
this seems to work but only for up to 4 letter words somehow.
I thought maybe I could do it using a string object to concatenate and then returning it as a characted array using stringobject.c_str(); but I would prefer not to do this unless I have to.
Any help is greatly appreciated.
Thanks.