I'm aware that there are many questions like mine, but reading several didn't help me. Probably because I'm new at programming and having a hard time with pointers.
As an exercise, I'm trying to create a function in c++ to reverse an inputted string. Here is my function:
char* reverse(const char* t)
{
int j, k;
char* aString = new char[100];
for(j=0, k=strlen(t)-1; j < strlen(t); j++, k--)
{
aString[j]=t[k];
}
aString[j+1]='\0';
return aString;
}
However, the input doesn't get reversed at all. What am I doing wrong?