Advertisement
ptrawt

259201 Lab9.1

Nov 4th, 2014
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     string str;
  10.    
  11.     cout<<"Enter string: ";
  12.     getline(cin,str);
  13.     cout<<"Input size: "<<str.size()<<endl;
  14.    
  15.     const char * tstr = str.c_str();
  16.     char rstr[str.size()];
  17.    
  18.     int j = 0;
  19.     for(int i = str.size()-1 ; i >= 0 ; i--)
  20.     {
  21.         rstr[i] = tstr[j++];
  22.     }
  23.    
  24.     cout<<"Reverse string: "<<rstr;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement