here's a function I tried to write that reverses the order of a c-string
void reverse(char *wordPtr)
{
char revWord[SIZE];
int count = 0, // index counter
newSize = 0; // to count word size
while (wordPtr[count] != '\0')
{
newSize += 1;
count++;
}
cout << "The size of the string you entered is " << newSize << endl;
for (count = 0; count < newSize; count++)
{
revWord[newSize - (count + 1)] = wordPtr[count];
}
cout << "the word backwords is " << revWord
<< endl;
}
wordPtr points to a character array in the main function
if I input "Hello" or anything else my output always has extra characters on the end. How do I get rid of those?