函数指针地址

/*strlen函数:返回字符串s长度*/
int strlen(char *s)
{
 int n;
 for(n=0;*s!='';s++)
  n++;
 return n;
}

#define ALLOCSIZE 10000 /*可用空间大小*/
static char allocbuf(ALLOCSIZE); /*alloc使用的存储区*/
static char *allocp=allocbuf;  /*下一个空闲位置*/
char *alloc(int n)     /*返回指向n个字符的指针*/
{
 if(allocbuf+ALLOCSIZE-allocp>=n) /*有足够的空闲空间*/
 {
  allocp+=n;
  return allocp-n;   /*分配前的指针p*/
 }else       /*空闲空间不够*/
 return0;

void afree(char *p)     /*释放p指向的存储区*/
{
 if(p>=allocbuf&&p<allocbuf+ALLOCSIZE)
  allocp=p;
}
 
 
原文地址:https://www.cnblogs.com/TheFly/p/11896042.html