Use assert() macro to check input - C Function

C examples for Function:Utility Function

Description

Use assert() macro to check input

Demo Code

#include <stdio.h>
#include <assert.h>

int main( void )
{
    int x;/* w  w w  .jav  a2 s  . c o m*/

    printf("\nEnter an integer value: ");
    scanf("%d", &x);

    assert(x >= 0);

    printf("You entered %d.\n", x);
    return 0;
}

Related Tutorials