>this seems to work but only for up to 4 letter words somehow.
It seems the size of a pointer is four bytes on your system.
>char * ret = (char*)malloc(sizeof(array) + 1 + 1);
sizeof doesn't do what you want here. It's giving you the size of a pointer, not the length of the string. If you want the length of the string, use strlen. And you really should be using new instead of malloc.
Last edited by Narue; Jun 12th, 2007 at 12:29 pm.
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Offline 11,807 posts
since Sep 2004