I am not getting reverse string using following code,
can u explain where i did mistake and correct it
with regards
sandeep
code-->>>
can u explain where i did mistake and correct it
with regards
sandeep
code-->>>
Code:
#include<stdio.h> #include<string.h> main() { char s1[100],s2[100],*p,*q; gets(s1); p=s1;q=s2; while(*p!='\0') p++; while(p>=&s1[0]) { *q++=*p--; } *q='\0'; printf("\ngiven string--->%s\n",s1); printf("\nreverse string--->%s\n",s2); }
Comment