Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How does C language judge whether the input number is an integer or a real number?
How does C language judge whether the input number is an integer or a real number?
(1) could have been judged by judging the number of bytes.

But in VC, both shaping and single precision account for 4 bytes.

Unable to judge

2 you can do this.

For example, for variable a

if(scanf("%d ",& ampa))

Printf ("it's plastic \n", x);

else if(scanf("%f ",& ampc)||scanf("%lf ",& ampc))

Printf ("is a real type \n", x);

As a result, I didn't even dare to try the computer

(3) and then the last method.

float a =-2;

if(a==int(a))

Printf ("it's plastic \ n");

other

Printf ("is a real type \ n");

This method is limited to judging whether A is only plastic or real.

I tried this method.

possible

Accept the answer.