C语言关于++--的问题

以前一直认为在C语言中只有整形数据才能进行++,--的自增运算,今天发现其实我错了。例如看下面的一个程序:

#include <stdio.h>
//#include <string.h>
int main(void)
{
 float x = 1;
 float y;
 y = ++x*++x;
 printf("%f\n",y);
 return 0;
}


在vc6.0中编译结果是这样的:
--------------------Configuration: test_one - Win32 Debug--------------------
Compiling...
test_One.cpp
test_One.obj - 0 error(s), 0 warning(s)
云行结果是这样的:
9.000000
Press any key to continue
而在vs2008中是这样的:
编译:
1>------ 已启动生成: 项目: testBKY, 配置: Debug Win32 ------
1>正在编译...
1>stdafx.cpp
1>正在编译...
1>testBKY.cpp
1>正在编译资源清单...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>正在链接...
1>正在嵌入清单...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>生成日志保存在“file://d:\Backup\我的文档\Visual Studio 2008\Projects\testBKY\testBKY\Debug\BuildLog.htm”
1>testBKY - 0 个错误,0 个警告
========== 生成: 成功 1 个,失败 0 个,最新 0 个,跳过 0 个 ==========
运行:
9.000000
Press any key to continue
可见不只是整形数据可以进行自增自减运算。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值