www.fltk.net > 使用sizEoF()运算符编写程序求在vC 6.0环境下int型、FloAt型、DouBlE型

使用sizEoF()运算符编写程序求在vC 6.0环境下int型、FloAt型、DouBlE型

#include <iostream> using namespace std; int main() { cout<<"int 长度" <<sizeof(int) <<endl <<"float 长度" <<sizeof(float) <<endl <<"double 长度" <<sizeof(double)<<endl; retrn 0; }

指针所占的字节数都是机器的位数 32位的机器占32/8=4字节 不用计算了吧 cout<<"sizeof(char*)="<<sizeof(char*)<<endl <<"sizeof(short*)="<<sizeof(short*)<<endl <<"sizeof(int*)="<<sizeof(int*)<<endl <<"sizeof(long*)="<<sizeof(long*)<<endl <<"sizeof(float*)="<<sizeof(float*)<<endl <<"sizeof(double*)="<<sizeof(double*)<<endl;

跟C里的一模一样. sizeof(类型名),sizeof(变量名)都可以.不需要写正式代码了吧,你应该能懂的

#include double growthRate(double B, double D){ return (B - D);}double estimatedPopulation(double P, double R, int N){ int i = 0; double NP = P;//n年后的人口数量,为了近似精确计算,用double类型 while (i 评论0 0 0

没错埃.printf("\n%d\n",sizeof(int));可以打出改系统中int定义变量占多少个字节.一般的是4个

#include <iostream.h> main() { cout<<"char:"<<sizeof(char)<<endl; }

搜一下:用sizeof操作符,求出int,char,flaot,double,unsigned int,long int等数据类型的字

float a = 1.f;double b = 2.;assert(sizeof(a+b)==sizeof(double));

4.5 x = 4.500000Press any key to continue void main() { double x; scanf("%lf", &x); //double输入请使用 lf float输入可以使用 %f printf("x = %f",x); } 有问题请追问 满意请记得采纳哦

#include <iostream.h> int main (void) { cout << "char size = " << sizeof(char) << " bytes\n"; cout << "char* size = " << sizeof(char*) << " bytes\n"; cout << "short size = " << sizeof(short) << " bytes\n"; cout << "int size = " << sizeof(int

相关搜索:

网站地图

All rights reserved Powered by www.fltk.net

copyright ©right 2010-2021。
www.fltk.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com