Skip to content

Instantly share code, notes, and snippets.

@ajinkya933
Created January 5, 2017 20:23
Show Gist options
  • Save ajinkya933/127a5b1b8d82234d4abd31c984e35bb9 to your computer and use it in GitHub Desktop.
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
#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