I am trying to check in C if an input is integer or a character or symbols like
ID: 3807032 • Letter: I
Question
I am trying to check in C if an input is integer or a character or symbols like .,!% etc.
I use scanf but it doesn't seems to work properly.
Source code:
printf("Enter the number ")
scanf ("%d",&number);
if (scanf("%d",&number!=1))
{printf("Not a integer ");}
Any ideas for a better code?
In my case firstly i have to exclude characters, all symbols like (,)(!) (#) (*) etc., pressing spacebar or even no input at all. After excluding all these i have to conclude (--> else) that input was integer. That is why i was trying to use scanf. Any ideas?
Explanation / Answer
Try This:
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.