Advertisement
darkhelmet125

301assign10

Oct 10th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void stringReverse(char stringToReverse[], int startSubscript);
  5.  
  6. int main()
  7. {
  8.     int leng=0;
  9.     int i=0;
  10.     char myWord[50]="";
  11.     cout<<"Please enter a string: ";
  12.     cin.getline(myWord,50);
  13.     while(myWord[i]!=NULL)
  14.     {
  15.         leng++;
  16.         i++;
  17.     }
  18.     stringReverse(myWord, leng);
  19.     return 0;
  20. }
  21.  
  22. void stringReverse(char stringToReverse[], int startSubscript)
  23. {
  24.     for(int i=startSubscript-1;i>=0;i--)
  25.     {
  26.         cout<<stringToReverse[i];
  27.     }
  28.     cout<<endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement