By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

question about "scanf"

P: n/a
Hi
I have problem:
My program reads 3 digits from keyboard using scanf("%d", &a)
then calculate it,everything is OK until I put "1,2,3,4,5,6,7,8,9,0"
but if I put "char " like "a,b,c,d etc" my program terminates :(
So,Is any method to verfity what kind of data is used(digits or chars)
if digits then OK if chars then show messege" use digits"
I'm beginer in C++ :(
Michal

Dec 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
news wrote:

Yeah, brilliant idea to crosspost to as many newsgroups as possible!
See my answer in alt.comp.lang.learn.c-c++.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.eai-systems.com> - Efficient Artificial Intelligence
Dec 20 '05 #2

P: n/a
Dietmar Kuehl wrote:
news wrote:

Yeah, brilliant idea to crosspost to as many newsgroups as possible!
See my answer in alt.comp.lang.learn.c-c++.


The OP *multiposted*. That's even worse!!!!!

--ag
--
Artie Gold -- Austin, Texas
http://goldsays.blogspot.com
http://www.cafepress.com/goldsays
"If you have nothing to hide, you're not trying!"
Dec 20 '05 #3

P: n/a
hi
the problem is that u r entering more integers than required
so first three integers are being used by scanf and the remaining are
implicitly given to the character input that is the reason u r not
getting the chance to input for the characters

ok bye
mail me if u want 2 be a friend of mine
mu************@yahoo.co.in

Dec 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.