首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

代码 bool函数编译无法通过

2012-05-22 
代码求助 bool函数编译无法通过/* Note:Your choice is C IDE */#include stdio.h#include malloc.h#i

代码求助 bool函数编译无法通过
/* Note:Your choice is C IDE */
#include "stdio.h"
#include "malloc.h"
#include "stdlib.h"

struct Arr{
int * pBase;
int len;
int cnt;
};

void init_arr(struct Arr *pArr);

void show(struct Arr *pArr);

bool is_Empty(struct Arr * pArr);

void main()
{
  struct Arr arr;
  // printf("%d\n",arr.len);
  init_arr(&arr,6);
  // printf("%d\n",arr.len);
  show(&arr);
}

void init_arr(struct Arr *pArr,int len){
//pArr->len=99;
pArr->pBase=(int *)malloc(sizeof(int)*len);
if(NULL==pArr->pBase){
printf("动态分配内存失败!");
exit(-1);
}else{
pArr->cnt=0;
pArr->len=len;
}
return;
}

bool is_Empty(struct Arr *pArr){
if(pArr->cnt==0){
return true;
}else{
return false;
}
}


void show(struct Arr *pArr){
int i;

if(is_Empty(pArr)){
printf("数组为空");

}else{
for(i=0;i<pArr->cnt;i++){
printf("%d ",pArr->pBase[i]);
printf("\n");
}
}
return;
}

[解决办法]

C/C++ code
void init_arr(struct Arr *pArr,int len);
[解决办法]
C89没有bool,用Int取代。
[解决办法]
c语言没有bool吧,windows API里都是BOOL,然后typedef int BOOL的
[解决办法]
他的那个后缀名是.cpp,而你的是.c。
探讨

好像c中真没有bool 可是 在郝斌老师的数据结构代码中 他就用了 我跟着敲的

热点排行