C类型与数值存储

来源:互联网 发布:python 缺省参数 编辑:程序博客网 时间:2024/05/16 17:12
#include <stdio.h>
#include <stdlib.h>




/* run this program using the console pauser or add your own getch, system("pause") or input loop */




void main(){
char ch = 'A';//为ch分配一个字节空间,把字符A存在当中,寸的是65,为A对应的ASKII码值 
int i = 1; //01 00 00 00 

}


/* 
void main(){
int a = 4;
void v;//void是无大小的,因此不知道给他的变量分配多少空间,所以会报错 
}
*/


/*
void main(){
//C++
//使用需要#include<iostream>和 using namespace  std; 

cout<<sizeof(char)<<endl;//cout为输出打印,endl为换行 
cout<<sizeof(short)<<endl;
cout<<sizeof(int)<<endl;
cout<<sizeof(long)<<endl;
cout<<sizeof(double)<<endl;
cout<<sizeof(bool)<<endl;
}
*/


/*
void main(){
printf("char = %d\n", sizeof(char));
printf("short = %d\n", sizeof(short));
printf("int = %d\n", sizeof(int));
printf("long = %d\n", sizeof(long));
printf("float = %d\n", sizeof(float));
printf("double = %d\n", sizeof(double));
//printf("bool = %d\n", sizeof(bool));





}




*/


/* 
int main(int argc, char *argv[]) {

//存储的值可以变化的量,为变量 
//用类型定义变量实质是给变量分配空间 。 
char ch;
short s;
int i;
long l;
float f;
double d;
bool b;
//void 无类型 
 
return 0;
}*/
0 0