+ 1

Code not working🥺

My below code keeps on getting input but I gave only 1 scanf function call. I'm confused, help me https://code.sololearn.com/c5CXiVz3zIEJ/?ref=app

18th Dec 2021, 8:23 AM
Rishi
Rishi - avatar
12 Respuestas
+ 5
Rishi You are not incrementing value of i here for (int i = 0; i < 9; max--)
18th Dec 2021, 8:32 AM
A͢J
A͢J - avatar
+ 4
Rishi the program does print "yo", but it is being held in the output buffer until the buffer is filled or the program exits normally. Unfortunately, the program exits abnormally due to an infinite loop caused by the failure to increment i. To see "yo", insert fflush(stdout); right after the printf. This forces a flush of the output buffer.
19th Dec 2021, 12:25 AM
Brian
Brian - avatar
+ 3
Rishi stdin, stdout, and stderr are file stream pointers, just like the return value from calling fopen() to open a disk file or I/O device. They are defined in stdio.h. The streams are already open at the start of your program. They may be redirected to other files or devices by syntax in the shell command line. Even your program may redirect them by calling freopen().
19th Dec 2021, 10:07 AM
Brian
Brian - avatar
+ 2
@AJSoloHelper I incremented it inside the first if condition. But even if that was the problem, the printf function in line 12 should print "yo" right?
18th Dec 2021, 9:49 AM
Rishi
Rishi - avatar
+ 2
Rishi, What was this code supposed to do?
18th Dec 2021, 1:30 PM
Ipang
+ 2
Ipang It sorts the array into "highest frequency first" but in a new array Martin Taylor this code is my friend's code. He's not a good code, but a good logical person. I saw the print statement after the scanf call, but didn't print "yo", so I wondered why it's not printed. But now as @Brain said, it's being held in the output buffer until the program exits, so it's not printed. Thank you all, now my doubt is cleared 😊
19th Dec 2021, 2:09 AM
Rishi
Rishi - avatar
+ 1
Rishi If program is running continuously then Sololearn compiler print nothing.
19th Dec 2021, 5:37 AM
A͢J
A͢J - avatar
0
Brian what is stdout here? For example, in Java "System" is a class. Like that, what is stdin and stdout? Like, some kind of variables?
19th Dec 2021, 2:19 AM
Rishi
Rishi - avatar