C标准库头文件 assert.h
@函数名称: assert
函数原型: void assert(int exp)
函数功能: 诊断类:表达式结果正确性测试并可使程序中止
函数返回:
参数说明: 将错误信息输出到流stderr中,如果exp为0,则中止程序执行.exp-表达式
所属文件: <assert.h>
#include <stdio.h>
#include <assert.h>
void process_string(char *string)
{
/* use assert to check argument */
assert(string!=NULL);
assert(*string!='/0');
/* rest of code follows here */
}
int main()
{
process_string("hello");
process_string("");
return 0;
}
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/lixinlu2000/archive/2006/11/18/1394975.aspx
本文介绍了C语言标准库中的assert函数,详细解释了其使用方法及功能。assert用于测试表达式的正确性,在开发过程中帮助开发者检查代码逻辑是否符合预期。当表达式结果为假时,assert会终止程序运行并输出错误信息。
398

被折叠的 条评论
为什么被折叠?



