How does the scanf function work in C?

前端 未结 7 1635
孤独总比滥情好
孤独总比滥情好 2020-12-06 13:48

Why do you require ampersand (&) in the scanf function. What will the output or type of error (compile or runtime) be in the following C code?



        
相关标签:
7条回答
  • 2020-12-06 14:18

    If you're asking a question like this, I would recommend just learning for now "it just does".

    You will learn that you need an ampersand because scanf takes one or more pointer arguments. If a is an int variable, it is not a pointer. &a ("the address of a") is a pointer, so it will work with scanf.

    0 讨论(0)
提交回复
热议问题