can any1 pls tell me how can i solve my problem?
i'm running a c program that required the user to key in a int, but instead of keying in int the user key in char... and somehow the program stor the char n turn it into int...
some even continue looping... how can i solve it... demanding for help...
blur blur 0 Newbie Poster
Recommended Answers
Jump to PostYou must first read in your text book how to code in C. This is not a good place to learn the very most basic things, but a place to come if you have written a program that is not working right, or maybe does not compile.
Jump to PostIf you want to prevent someone from entering anything other than numeric digits I would get then to enter a string instead of int, then check the string for digits.
char input[255] = {0}; // input buffer char *ptr; printf("Enter a number\n"); fgets(input,sizeof(input),stdin); // get keyboard // …
All 6 Replies
griswolf 304 Veteran Poster
blur blur 0 Newbie Poster
griswolf 304 Veteran Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
blur blur 0 Newbie Poster
thekashyap 193 Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.