I'm doing a code in which a user inputs a word and then I have to output the word backwards, but for some reason, the black screen disappears when I enter the word...here's my code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string word,backwards;
int numchars=0;
cout << "Enter word : " ;
getline(cin,word);
numchars = int(word.length());
for(int i=numchars;i>=0;i--)
{
backwards = word.at(i);
}
cout << "The word backwards is : " << backwards << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
What am I doing wrong?