博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

嵌入式linux

构建完善的嵌入式linux平台
   uClinux.cublog.cn
关于作者  
姓名:panhuachun@hotmail.com
职业:软件工程师
年龄:24
位置:China
个性介绍:构建优美的嵌入式平台

我的分类  




数组名总结
#include <string.h>
#include <stdio.h>
#include <time.h>
/*
   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));
}

 发表于: 2008-03-08,修改于: 2008-03-08 16:29 已浏览131次,有评论1条 推荐 投诉

  网友评论
  本站网友 时间:2008-03-20 16:53:11 IP地址:60.209.248.★
不错!!!


  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:12.56992

京ICP证041476号