关于功能默认返回值? [英] Regarding function default return value?

查看:79
本文介绍了关于功能默认返回值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

e.g。 func在执行时返回11?任何人都可以解释它的原因吗?

e.g. The func returns 11 on this execution? Can anyone elucidate its reason?

展开 | 选择 | Wrap | 行号

推荐答案

你在哪里看到11?


我所看到的只是Hello world。是的,printf返回显示的字符数,在这种情况下是11但你没有捕获11。
Where are you seeing 11?

All I see is "Hello world". True, printf returns the number of characters displayed which in this case is 11 but you are not capturing the 11.


好的,让我修改代码使其更容易理解:

Ok, Let me modify the code to make it more understandable:

展开 | 选择 | Wrap | 行号


这真的很有趣。


您将获得传递给 printf 函数的字符串的字符串长度。


但不是全部 printf 。如果你在这种情况下再添加10个printf,你将只获得最后一个 printf 函数中的最后一个字符串长度。


我不确定但可能是我从某个地方读取或听到该函数使用AX / EAX寄存器返回值。


如果此信息为真,那么 printf 函数很可能使用AX / EAX寄存器,但它不会重置寄存器。这就是为什么作为回报你得到11这是你的字符串长度。
This is really interesting.

You are getting the string length of the string that is passed to printf function.

but not all printf. if you add 10 more printf in this case you will get only the last string length in the last printf function.

I am not sure but may be i read or heard from somewhere that function use AX/EAX register to return value.

If this information is true then it is very much possible that printf function use AX/EAX register but it do not reset the register. that is why in return you are getting 11 which is your string length.


这篇关于关于功能默认返回值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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