0

Can you tell the reason why this code is crashing?

Program :- #include<stdio.h> void string(char *name,int n) { printf("%s\n",n+1,name); n++; if(n<10) { string(name,n); } } int main() { char name[20]; printf("enter the name\n"); scanf("%s",&name); string(name,0); } The output should be like enter the name 1 HELLOW WORLD 2 HELLOW WORLD . . . . . 10 HELLOW WORLD

12th Aug 2020, 4:32 AM
Md Ashraf Hussain
Md Ashraf Hussain - avatar
1 Antwort
+ 4
List of errors :- 1) in line "scanf("%s",&name)". "name" is already a pointer so reference of it should not be passed 2) in line printf ("%s\n",n+1,name). You are passing more arguments than specified by format specifier Here is the fix👇 https://code.sololearn.com/c3GeaHdAif8W/?ref=app
12th Aug 2020, 4:48 AM
Arsenic
Arsenic - avatar