fork download
  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4.  
  5. void rev(char s[]){
  6. for(int i=0,j=strlen(s)-1;i<j;i++,j--){ char t=s[i]; s[i]=s[j]; s[j]=t; }
  7. }
  8.  
  9. int main(){
  10. char s[100];
  11. printf("Enter string:\n ");
  12. gets(s);
  13. rev(s);
  14. printf("Reversed=%s",s);
  15. }
  16.  
Success #stdin #stdout 0s 5292KB
stdin
hello world
stdout
Enter string:
 Reversed=dlrow olleh