您的位置:首页 > 编程语言 > C语言/C++

C标准库学习之<assert.h> ——诊断

2017-01-24 17:08 387 查看
#include <stdio.h>
#include <assert.h> // 诊断

/*
=========================================================
time:           2017年1月24日17:04:51
objective:      test C language's  head file of <assert.h>
version:        Microsoft Visual C++
author:         ChenFei
remark:         日文system  部分汉字需用拼音代替
=========================================================
*/

int main(void)
{
int a;
char str[50];

printf("Please enter a value.");
scanf("%d", &a);

assert(a >= 10);                        // assert(ture),程序继续执行

printf("Entered number is %d\n", a);    // assert(false),程序跳出错误窗口,并打出错误信息。

printf("Please input string. ");
scanf("%s", &str);

assert(str != NULL);

printf("The input string is %s\n", str);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c语言