fork(2) download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. char str1[10];
  5. char temp;
  6.  
  7. char *sptr1;
  8. char *sptr2;
  9. int len;
  10. printf("Enter a string:\n");
  11. scanf("%s",str1);
  12. sptr1=str1;
  13. sptr2=str1;
  14. while(*sptr1!='\0')
  15. {
  16. sptr1++;
  17. }
  18. len=sptr1-str1;
  19. printf("Length of the string:%d\n",len);
  20. sptr1--;
  21. while(len>0)
  22. {
  23. temp=*sptr1;
  24. *sptr1=*sptr2;
  25. *sptr2=temp;
  26.  
  27. sptr1--;
  28. sptr2++;
  29. len=len-2;
  30. }
  31. printf("%s\n",str1);
  32. }
Success #stdin #stdout 0s 9424KB
stdin
aiaz
stdout
Enter a string:
Length of the string:4
zaia