为什么printf("%f\n",5)输出0.000000
来源:互联网 发布:淘宝宝贝标题是什么 编辑:程序博客网 时间:2024/05/17 03:58
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int xx[2];
int *pp1=xx;
*pp1=5;
//*(pp1+1)=0;
double *pp=reinterpret_cast<double*>(xx);
cout<<"int:"<<*pp1<<" , "<<*(pp1+1)<<endl;
cout<<(*pp)<<endl;
printf("同一块内存区域double 输出:%f\n",*pp);
printf("同一块内存区域int 输出:%f\n",xx[0]);
cout<<pp1<<" , "<<pp1+1<<" , "<<pp1+2<<endl;
cout<<pp<<" , "<<pp+1<<endl;
}
运行结果
int a=5//无论a等于任何数输出都是0.000000;
printf("%f\n",a);
应该是printf函数内部设置当int类型按照double输出时都输出0.000000。
0 0
- 为什么printf("%f\n",5)输出0.000000
- 【转】printf("%f/n",5)的输出结果为什么是0.000000
- printf("%f\n",5)
- printf("%f\n",5);/
- printf 使用%f输出整形变量,为什么为0?
- printf("%f/n",5)的问题
- printf("%f\n", 3);
- printf("%f\n", 3);
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- printf("%d",5.01)和printf("%f",5)的输出结果
- 在c语言中执行这两条语句printf("%d/n", 5.01);printf("%f/n", 5);
- eclipse配置android NDK开发环境
- linux定时器和Jiffies
- android tabhost里捕获后退按键
- 关于优先级队列STL
- Python,Django安装MySQLdb各种经典错误(Error No module named MySQLdb)
- 为什么printf("%f\n",5)输出0.000000
- 使用supervisord来管理process
- UVA 10192 Vacation LCS
- Premature end of file 错误解决 (2011-01-21 10:02:22)
- Xcode 4.3中在iOS上应用Static Library及Static Framework笔记
- ALGOL
- FTP SFTP SCP OpenSSL SSH
- POJ 1691 Painting A Board
- Linux命令:top