This is my previous codes:
After changing fflush(stdin) to if ( (scanf("%d",&num) !=1)Code:printf("Please key in Sales Agent's code number>");/* Output statement*/ scanf("%d", &num); fflush(stdin); while( !(num >= 1000 && num <= 9999) )/*if the condition is not true then print the error message*/ { printf("\aInvalid code number! Please key in 4 digits code number.\n"); main(); }
when i input a alphabet for variable num it will cause the problem to do a infinity loop.