question about "scanf"

N

news

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
 
D

Dietmar Kuehl

news wrote:

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

Artie Gold

Dietmar said:
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
 
M

muni_esanakula

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
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Question about my projects 3
about scanf() 2
question about scanf 11
Problem with scanf 7
avoid newline scanf 6
scanf and ampersand 4
Dynamic Array Size Problem?? 9
question on assignment suppression in scanf 2

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top