当前位置: 代码迷 >> C语言 >> 一个感悟,请大家试试,一会再谈
  详细解决方案

一个感悟,请大家试试,一会再谈

热度:110   发布时间:2007-10-07 04:10:10.0

额 看看先


----------------解决方案--------------------------------------------------------
关注..
----------------解决方案--------------------------------------------------------

来做几个试验吧
#include <stdio.h>
fun()
{}
main()
{
printf("%d",fun(0,2));
getchar();
}
运行结果是0;
********************************
#include <stdio.h>
fun()
{}
main()
{
printf("%d",fun('0','2'));
getchar();
}
运行结果是48;48是字符'0'的ASCII码值;
********************************
#include <stdio.h>
fun()
{}
main()
{
printf("%d",fun('2','0'));
getchar();
}
运行结果是50;50是字符'2'的ASCII码值;
*******************************
#include <stdio.h>
int a=0,b=2;
fun(int)
{}
main()
{
printf("%d",fun(a,b));
getchar();
}
没通过编译,错误是在调用函数fun时有额外的参数
――――――――――――――――――――――
上面四个程序对比得出的结论是:1,当函数没有返回类型时,编译器(我用的TC3.0)默认返回int型
2,当函数有参数时,默认返回第一个参数所对应int型值
3,当函数声明时有对参数的说明,则调用时必须保持和声明一致


----------------解决方案--------------------------------------------------------
回复:(栖柏)一个感悟,请大家试试,一会再谈
ding
----------------解决方案--------------------------------------------------------
返回值在cpu内部的ax eax 或者 浮点寄存器中..

在调用fun函数的过程中,
参数入栈和开辟局部变量空间并初始化的操作以及函数内的操作

对 ax eax 或浮点寄存器的修改就影响了返回值.




----------------解决方案--------------------------------------------------------
要想搞清楚这个还要点汇编知识啊
----------------解决方案--------------------------------------------------------
回复:(limeng_HOHO)来做几个试验吧#include
#include <stdio.h>
fun()
{}
main()
{
printf("%d",fun('0','2'));
getchar();
}
运行结果是48;48是字符'0'的ASCII码值;
********************************
#include <stdio.h>
fun()
{}
main()
{
printf("%d",fun('2','0'));
getchar();
}
运行结果是50;50是字符'2'的ASCII码值;
我用tc2.0运行怎么得不到 ‘0’和‘2’的ASCII码值?
----------------解决方案--------------------------------------------------------

An employee named Fren comes to you asking for help with the power settings on her portable Windows 2000 Professional computer. She wants to maximize battery life by having all devices power off when she presses the sleep button. When she restores power, she wants to begin where she last left off (ie, she does not want to have to boot the computer). What power option or scheme do you recommend for her?

a. Standard options.
b. Power Off option.
c. Hibernate option.
d. Always On power scheme.
e. Portable power scheme


----------------解决方案--------------------------------------------------------

use standard writting, it's important.


----------------解决方案--------------------------------------------------------
TC2.0上面是1,不过这很正常吧。我记得教材上面就讲过对参数不严。
----------------解决方案--------------------------------------------------------
  相关解决方案