0

Why not code coach problem is not solved from this code? Extra t. All case are solved only 5 one is not solve why tell me. 🙏

#include <stdio.h> void reverse (char *a) { if (*a) { reverse (a+1); printf ("%c",*a);}} int main() { char a[30]; scanf("%[^n]s",&a); reverse (a); return 0; }

29th Oct 2020, 9:12 AM
Habit🧐🧐
Habit🧐🧐 - avatar
6 Answers
+ 1
It's "\n" not "n"
30th Oct 2020, 12:26 PM
Davide
Davide - avatar
+ 1
Thanks 🙏
30th Oct 2020, 1:16 PM
Habit🧐🧐
Habit🧐🧐 - avatar
0
The problem is in the scanf. You meant to do [^\n] and also you don't need the '&' because the array name is a pointer. edit. Anyway as a suggestion: the problem is not that complex to require a recursive function. A simple for loop can do the job. Try to make a more efficient recursive solution.
29th Oct 2020, 12:03 PM
Davide
Davide - avatar
30th Oct 2020, 3:16 AM
Habit🧐🧐
Habit🧐🧐 - avatar
0
I make this one but it not successful
30th Oct 2020, 3:17 AM
Habit🧐🧐
Habit🧐🧐 - avatar
0
[^n] is important with it not reverse second word
30th Oct 2020, 3:18 AM
Habit🧐🧐
Habit🧐🧐 - avatar