Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307885
  • 博文数量: 20
  • 博客积分: 3011
  • 博客等级: 中校
  • 技术积分: 440
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-12 10:01
文章分类

全部博文(20)

文章存档

2008年(20)

我的朋友

分类: C/C++

2008-03-08 16:29:09

#include
#include
#include
/*
   BOOL型变量:if(!var)
   int型变量: if(var==0)
   float型变量:
     const float EPSINON = 0.00001;
     if ((x >= - EPSINON) && (x <= EPSINON)
   指针变量:  if(var==NULL)
*/
 
/*
#define MIN(A,B) ((A) <= (B) ? (A) : (B))
#define LREG (*(volatile unsigned int *)0x50000000)
#define READ_LREG LREG
#define WRITE_LREG(ch) (LREG = (unsigned int)(ch))
*/

//int volatile i; //全局变量,在其它地方会被修改
int   i; //全局变量,在其它地方会被修改
int  *volatile p;

void do_somethings(void )
{
 i=0;
}
/*  
 数组名的本质如下:
  (1)数组名指代一种数据结构,这种数据结构就是数组;
  (2)数组名可以转换为指向其指代实体的指针,而且是一个指针常量,不能作自增、自减等操作,不能被修改;
  char str[10];
  str++; //编译出错,提示str不是左值 
  (3)数组名作为函数形参时,沦为普通指针。
*/
void fun(char str[100])
{
printf("%d\n",sizeof(str));//结果为4
printf("%d\n",strlen(str));
}
main()
{
int *p;
char *pp;
pp=(char *)malloc(10*sizeof(char));
if(pp==NULL)
 exit(1);
char ppp[100];
memset(ppp,'\0',100);
memset(ppp,'3',99);
printf("%d\n",sizeof(ppp));
fun(ppp);
i=1;
p=&i;
while (*p==1)
{
 printf("----------\n");
 do_somethings();
}
printf("%d\n",sizeof(double));
printf("%d\n",sizeof(float));
printf("%d\n",sizeof(short));
printf("%d\n",sizeof(long));
printf("%d\n",sizeof(long long));
}
阅读(815) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2008-03-20 16:53:11

不错!!!