- 2

Can anyone help me in solving extra terrestrial code in c by using string reverse function.

9th May 2021, 6:57 AM
Guntumadugu Rakesh
4 Respuestas
+ 1
show your attempt Guntumadugu Rakesh
9th May 2021, 7:06 AM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar
+ 1
Ive had difficulty with this one too... Stick to it for 6 montha and problems like this will seem easy.
10th May 2021, 1:34 PM
Richard Horvatich
Richard Horvatich - avatar
0
strrev is not a C standard function , so in most of the compiler it doesn't work ! so , solve by counting number of characters in string (by strlen()) , apply loop from last (length of string) to first ! Ex: char str[100]; scanf("%s",str); int length=strlen(str); /*strlen counts no.of characters in string except null , use string.h header file .*/ for(int i=length-1 ; i>=0 ; i--) printf ("%c",str[ i ] );
10th May 2021, 5:27 AM
Giriraj Yalpalwar
Giriraj Yalpalwar - avatar
- 2
#include <stdio.h> #include<string.h> int main() { char str1[20]; scanf ("%s",str1); strrev (str1); printf("%s",str1); return 0; }
9th May 2021, 10:36 AM
Guntumadugu Rakesh