+ 4

How to reverse a string in C language??

I want to reverse a string in C . But I don't know if I have to use Arrays in C or Some kind of iteration or looping. Please help me.

13th Jan 2020, 1:45 PM
JEET DHOLAKIA
JEET DHOLAKIA - avatar
6 Respuestas
+ 3
Take another array , and in that copy each char from last to first . Or simply use strrev()
13th Jan 2020, 1:57 PM
Shubham Vilayatkar
Shubham Vilayatkar - avatar
+ 2
https://code.sololearn.com/csnpYPK7hDKC/?ref=app You can search in code section more.
13th Jan 2020, 1:50 PM
Mihai Apostol
Mihai Apostol - avatar
+ 2
Thanks a lot
13th Jan 2020, 2:24 PM
JEET DHOLAKIA
JEET DHOLAKIA - avatar
+ 2
Thanks
15th Jan 2020, 10:35 AM
JEET DHOLAKIA
JEET DHOLAKIA - avatar
0
#include<stdio.h> int main() { int i,j,n; char s[100]; printf("enter...."); scanf("%[^\n]s",s); n=strlen(s); printf("len=%d\n",n); for(i=n-1;i>=0;i--){ n=n-1; printf("%c",s[n]);} return 0; }
15th Jan 2020, 10:34 AM
Saritha Chinnu
Saritha Chinnu - avatar
0
How to creat backslash on android phone?
30th Jan 2020, 12:06 PM
shekhar hivrale
shekhar hivrale - avatar