Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Weird usage of printf/scanf? Why do they work?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Barry Schwarz, post: 3936175"] My compiler generates the expected diagnostics: D:\Barry\C\Programs\Test\test1.c(23) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int ' D:\Barry\C\Programs\Test\test1.c(23) : warning C4024: 'printf' : different types for formal and actual parameter 1 I don't use gcc but I am a little surprised that after invoking the compiler it does not produce any output upon finishing. Maybe you could add an additional statement with a subtle error and tell him to compile it for you. During execution the program fails (with an unhandled exception) after accepting the input, also as expected. While the calls to printf are syntactically acceptable, on my system the only output is the first string argument in each call, all on the same line. This will not assign values to input2 and input3. This invokes undefined behavior by attempting to evaluate variables with indeterminate values. On my system, none of the if statements evaluated to true (input2 and input3 happened to have the same large negative value). On my system, the calls to printf printed out only the initial string argument in each call - Sum is, Average is, Product is, Largest is. All were on the same line. Another possibility is that he is typing in the output instead of compiling and executing the programs. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Weird usage of printf/scanf? Why do they work?
Top