this code does nothing. why is it there?
Quote:
Originally posted by M3GAPL3X
Code:
while (strng[i]) //while string isn't a null character '\0'
i++; //increment i and store in string
strng[i] = '\0';
|
the inner loop shouldn't be there. think about how the characters will be copied. strng[0] -> reverse[n - 1], strng[1] -> reverse[n - 2] and so on. you only need one loop for this.
also, remember to put the '\0' at the end of 'reverse'.
Quote:
Code:
n = strlen(strng); //find the length of the string after
for (i=0; i < n; i++)
for (j = n; j >= 0; j--)
reverse[i] = strng[j];
//i--;
|