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

来源:互联网 发布:监控app软件排行 编辑:程序博客网 时间:2024/04/29 12:21
#include <stdio.h>#include <assert.h> // 诊断/*=========================================================time:           2017年1月24日17:04:51objective:      test C language's  head file of <assert.h> version:        Microsoft Visual C++author:         ChenFeiremark:         日文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;}
0 0