21st Feb 2019, 9:35 AM
Ak 👩‍💻 💻
Ak 👩‍💻 💻 - avatar
6 ответов
+ 2
Check for three characters it is giving correct result but for 4 variables it gets changed
23rd Feb 2019, 9:51 AM
Ashutosh Kumar
Ashutosh Kumar - avatar
+ 1
Solved :-- #include <stdio.h> int main() { void reverse(char *); // prototype declaration locally. char str[100]; printf ("Enter the string: "); scanf("%s",&str); reverse(str); printf("The reverse string is %s",str); return 0; } void reverse(char *str) { int i,j; char *s,*beg,*end; for(i=0; *(str+i)!='\0'; i++); // i counts the length of the string str. beg=str; //initially start of string end=str; //pointer moved to last character for(j=i-1;j>0;j--) end++; //swaping and updating value for (j=i-1; j>0; j--) { s=*end; *end=*beg; *beg=s; beg++; end--; } }
22nd Feb 2019, 10:07 AM
Ashutosh Kumar
Ashutosh Kumar - avatar
+ 1
#include <stdio.h> int main() { char *reverse(char *); // prototype declaration locally. char str[100]; printf ("Enter the string: "); scanf("%s",&str); reverse(str); printf("The reverse string is %s",str); return 0; } char *reverse(char *str) { int i,j; char *s,*beg,*end; for(i=0; *(str+i)!='\0'; i++); // i counts the length of the string str. beg=str; //initially start of string end=str; //pointer moved to last character for(j=i-1;j>0;j--) end++; //swaping and updating value for (j=i-1; j>0; j--) { s=*end; *end=*beg; *beg=s; beg++; end--; } return (&s); }
23rd Feb 2019, 9:25 AM
Ashutosh Kumar
Ashutosh Kumar - avatar
+ 1
Check again, this is what you wanted.
23rd Feb 2019, 9:26 AM
Ashutosh Kumar
Ashutosh Kumar - avatar
0
The problem is almost solved. I'll post the final answer soon.
24th Feb 2019, 8:33 AM
Ak 👩‍💻 💻
Ak 👩‍💻 💻 - avatar
- 1
I think some logical errors I will solve it
23rd Feb 2019, 9:52 AM
Ashutosh Kumar
Ashutosh Kumar - avatar