string). Send the text to a function called ReverseIt. This function will fill a second C-string so
that the original string is reversed (as described in Problem 26). Limit the size of the C-strings to
fifty characters. The last charac- ter in the original string (before the null) should be the first
character of the second string. Write both C-strings from main. Incorporate a loop so that the
user can continue to enter strings until he chooses to stop
Solution
#include
#include
using namespace std;
void ReverseIt(char *saying,char *reverse)
{
int len = (int)strlen(saying);
int j = len-1;
int i = 0;
while(j>=0)
{
reverse[i] = saying[j];
i++;
j--;
}
reverse[i] = \'\\0\';
}
int main() {
char saying[50],revsaying[50];
cout << \"Input a saying : \";
cin.getline(saying,sizeof(saying));
cout << saying << endl;
ReverseIt(saying,revsaying);
cout << revsaying;
return 0;
}