Hi, I'm trying to write a program that accepts a string (a line, sentence, or phrase) and then the program has to display the contents of that string backward. for example, if I entered "starting out" the program has to convert it to "tuo gnitrats".
This is my code. But I don't know what's wrong with it.
//project #2 backward String (follow page 515, 519)
//write a function that accepts a pointer to a C-string as an argument and displays its contents backwards.
# include <iostream.h>
//function Prototype
void Backward (char *);
void main (void)
{
char line[201];
cout << "This program will display the contents of the entered phrase backward.\n";
cout << "Please enter a phrase of no more than 200 characters, followed by a period.\n";
cin.getline(line, 201);
cout << "The entered string displayed backward: \n";
cout << Backward (line) << endl;
}
void Backward (char *sentencePtr)
{
char *sentencePtr = set;
while (*sentencePtr != '\0' && *sentencePrt > set)
{
sentencePtr--;
cout << *sentencePtr << endl; //or return sentencePtr;
}
}
can anyone help please?