“printf” only printing variable addresses

后端 未结 2 1871
青春惊慌失措
青春惊慌失措 2021-01-27 03:45

so here is my code:

#include 
main(){
int hi;
hi = 3;
printf(\"%d\",&hi);
}

and the output is: \"2686748\"

im using

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-27 04:00

    If you intend to print the value of hi, just pass it to printf, not its address:

    printf("%d", hi);
    

    You may be confusing printf with scanf, the latter requiring all of its arguments to be pointers.

提交回复
热议问题