以下代码的输出是什么? [英] What is the output of the below code?

查看:46
本文介绍了以下代码的输出是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

void main()
{
printf(3+"Helloworld\n");
}





我的输出为低世界。前三个字符被删除。 printf如何在这里工作?



Im getting output as loworld. First three characters are removed. How does printf working here?

推荐答案

printf需要一个指向字符串的指针,编译器在你的exe的STATIC部分存储字符串Helloworld \ n ,并引用该指针 - 你正在向它添加3,所以printf将从指针+ offset3开始..因此'loworld \ n'
printf expects a pointer to a string, the compiler is storing the string "Helloworld\n" in your STATIC portion of your exe, and referring to that pointer - you're adding 3 to it, so printf will start at the pointer+offset3 .. hence 'loworld\n'


这篇关于以下代码的输出是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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