I am supposed to reverse an entered string, I was given the hint that you basically copy the string into another one and then reverse from there but I am not sure how to actually do the reversal. Below is the code I have so far. This succesfully copies the string but im not sure how to reverse, help would be great
Code:
# include <stdio.h>
void strrev (char [], char []);
int main ()
{
#define lsize 81
char message[lsize];
char newmessage [lsize];
printf ("Enter a sentence: ");
gets (message);
strrev (newmessage, message);
puts (newmessage);
system ("PAUSE");
return 0;
}
void strrev (char string1[], char string2[])
{
int i=0;
while (string2[i] != '\0')
{
string1[i]=string2[i];
i++;
}
string1[i]='\0';
}