“printf"只打印变量地址 [英] "printf" only printing variable addresses

查看:61
本文介绍了“printf"只打印变量地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

#include <stdio.h>
main(){
int hi;
hi = 3;
printf("%d",&hi);
}

输出为:2686748"

and the output is: "2686748"

我在 Windows 7 上使用代码块"

im using "code blocks" on Windows 7

任何想法有什么问题??

any ideas whats wrong??

推荐答案

"%d" 告诉 printf 你正在输入一个整数.你给它的整数是&hi,它是hi 的地址.如果你想要 hi 的值,就用那个

The "%d" tells the printf you are putting in an integer. The integer you are giving it is &hi which is the address of hi. If you want the value of hi just use that

这篇关于“printf"只打印变量地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆