Created
January 5, 2017 20:23
-
-
Save ajinkya933/127a5b1b8d82234d4abd31c984e35bb9 to your computer and use it in GitHub Desktop.
reverse a cstring in C++,
note that cstring is the same string that is used in C compiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstring> | |
using namespace std; | |
int main() | |
{ | |
char str[255]; | |
cout<<"Write something here"; | |
cin.getline(str,255); | |
int len=strlen(str); | |
int i; | |
cout<<str<<"Length"<<strlen(str)<<endl; | |
for (int i = len-1; i >=0 ; i--) { | |
cout<<str[i]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment