C 语言下 BOOL TRUE FALSE的使用
来源:互联网 发布:淘宝怎么设置下架时间 编辑:程序博客网 时间:2024/05/06 19:57
<pre name="code" class="cpp">#include <stdio.h>#include <stdlib.h>#define BOOL int // C语言 巧妙的使用 宏来解决C语言不支持 BOOL类型的问题 #define TRUE 1 // C语言 巧妙的使用 宏来解决C语言不支持 TRUE类型的问题 #define FALSE 0 // C语言 巧妙的使用 宏来解决C语言不支持 FALSE类型的问题 struct array{int count;int size;char *pBase;};void init_arr (struct array *pArr,int number);void show_arr (const struct array *pArr);BOOL is_empty (const struct array *pArr);int main (void){struct array arr;init_arr (&arr,10);show_arr (&arr);return 0;}void init_arr (struct array *pArr,int number){pArr->pBase = (char *)malloc(sizeof(char)*number);if (NULL == pArr->pBase){printf ("Memory allocation failed!\a\n");exit(EXIT_FAILURE);}else{pArr->size = number;pArr->count = 0;}return;}void show_arr (const struct array *pArr){int i;if ( is_empty(pArr) )printf ("Array is empty!\a\n");else{for (i=0;i<(pArr->count);i++)printf ("%c ",pArr->pBase[i]);printf ("\n");}return;}BOOL is_empty (const struct array *pArr){if (pArr->count == 0)return TRUE;elsereturn FALSE;}
0 0
- C 语言下 BOOL TRUE FALSE的使用
- c语言中如何使用bool true false
- BOOL,TRUE,FALSE 和 bool ,true, false
- bool true false
- C语言基础 bool型变量定义及初始化 用true与false
- BOOL与bool TRUE与true FALSE与false 区别
- c语言中bool型的使用
- js bool true false 真假比较
- js bool true false 真假比较
- C语言之加入头文件<stdbool.h>可以使用true和false
- 很多C编译不支持bool型,导致出现false和true未定义
- Debug日志:BOOL与bool,TRUE与true,FALSE与false
- true false 与TRUE FALSE 的区别
- FALSE/TRUE与false/true的区别
- FALSE/TRUE与false/true的区别
- FALSE/TRUE与false/true的区别
- FALSE/TRUE与false/true的区别
- bool不初始化的后果:既不为false也不为true
- python socket and select
- 短时傅里叶变换的原理与应用:电话拨号声分析(2)
- 第一个字符设备驱动程序
- background属性总结
- activiti之节点监听器结合业务的使用(让业务和流程完全分离)
- C 语言下 BOOL TRUE FALSE的使用
- [UIApplication _runWithMainScene:transitionContext:completion:]
- SourceKitService 占用过高CPU和内存
- NOIP专题复习——专题八:数论基础
- 互联网时代的密码记忆模型
- JAVA实现最短距离算法之迪杰斯特拉算法
- 利用maven将项目依赖的jar提取到指定文件夹
- 需求分析——确定需求细节(规则与约束)
- WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!解决方案