How does the scanf function work in C?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: 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? #include void main () { int a ; printf ( "enter integer:" ); scanf ( "%d" , a ); } 回答1: The & in C is an operator that returns the address of the operand. Think of it this way, if you would simply give scanf the variable a without the & , it will be passed to it by-value, which means scanf will not be able to set its value for you to see. Passing it by-reference (using & actually passes a