fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include<string.h>
  4.  
  5. int main() {
  6. char s1[50]="BANANA";
  7. int n=strlen(s1)-1;
  8. for(int i=0;i<n;i++)
  9. {
  10. char temp=s1[i];
  11. s1[i]=s1[n];
  12. s1[n]=temp;
  13. n--;
  14. }
  15. printf("string is=%s",s1);
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
string is=ANANAB