View Single Post
Old 07-14-2003, 01:59 PM   #6 (permalink)
Unicorn
Registered User
 
Unicorn's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 11
Unicorn is on a distinguished road
Writing a function to reverse a string is a good way to get familiar with the language. In future projects however, you might want to use the reverse function from the standard C++ library:

Code:
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int main (int argc, char **argv)
{
  char sentence[100];
  cin.getline (sentence, 100);
  reverse (sentence, sentence + strlen (sentence));
  cout << sentence << endl;
  
  return 0;
}
Unicorn is offline   Reply With Quote