PracticeDev/study_cpp/cpp_primer_source_code/Chapter 5/forstr1.cpp

19 lines
390 B
C++
Raw Normal View History

2022-12-20 17:31:11 +08:00
// forstr1.cpp -- using for with a string
#include <iostream>
#include <string>
int main()
{
using namespace std;
cout << "Enter a word: ";
string word;
cin >> word;
// display letters in reverse order
for (int i = word.size() - 1; i >= 0; i--)
cout << word[i];
cout << "\nBye.\n";
// cin.get();
// cin.get();
return 0;
}