+ 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
12 Respuestas
+ 5
Rishi
You are not incrementing value of i here
for (int i = 0; i < 9; max--)
+ 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.
+ 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().
+ 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?
+ 2
Rishi,
What was this code supposed to do?
+ 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 😊
+ 1
Rishi
If program is running continuously then Sololearn compiler print nothing.
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?