rootUser

Reverse string

May 27th, 2016
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* C programme to print reversely a given string */
  2. #include<stdio.h>
  3. #include<string.h>
  4. int main(void)
  5. {
  6.     int i,j=0,x;
  7.     char a[999999];
  8.     char b[999999];
  9.     printf("Please enter string:\n");
  10.     gets(a);
  11.     x=strlen(a)-1;
  12.     for(i=x;i>=0;i--)
  13.     {
  14.         b[j]=a[i];
  15.         j++;
  16.     }
  17.     b[j]='\0';
  18.     puts(b);
  19.     return 0;
  20. }
Add Comment
Please, Sign In to add comment