I have just begun learning pointer operations, and am attempting to create a function that will reverse a string. For some reason, however, revString is always allocated with an extra 4-5 bytes. The code is below, and I would appreciate anyone's help.
Code:
char *strrev(char *string)
{
int n=strlen(string);
char* revString=new char[n];
while( n-- )
*(revString+n) = *(string++);
return revString;
}