Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to check if the input is of type int
How to check if the input is of type int

All our inputs are characters. What the system can do is convert the input characters into corresponding characters according to your format control requirements. If there is a statement: scanf("%d",&a); Enter 45, and the system will convert the string "45" into an integer. This is all done automatically.

If you want to make a human judgment, it is very simple:

while(c=getchar())

if(c>='0'&&< ='9') It is an integer;

else if(c=='.') It is a real number;

esle It is character data;

This is the case in C language. If it is used in other object-oriented programming, it is also based on this principle, but an exception will be thrown when the input type is incorrect.