c home work

Reply

Join Date: Nov 2006
Posts: 2
Reputation: MasterBlast is an unknown quantity at this point 
Solved Threads: 0
MasterBlast MasterBlast is offline Offline
Newbie Poster

c home work

 
0
  #1
Nov 26th, 2006
i am new student i had a home work but i cant get this done
how can i input in the same line a char and two integers
the output should be like this :

please enter candidate family condition, defect percent,
children number, working condition: s 20 0 1

in my program i wrote it like this:
  1. printf("please enter candidate family condition, defect percent,
  2. children number, working condition: ");
  3. scanf("%c,%d,%d,%d",&status,&defect,&chnum,&w_cond);
i dont get it right when i input this : s 20 0 1
i tried without space even,but the teacher told us we have to input the data in one line and spaces between them

i would be happy if anyoe could help me
thx
Last edited by ~s.o.s~; Nov 27th, 2006 at 12:20 pm. Reason: Added code tags.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,346
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1460
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: c home work

 
0
  #2
Nov 26th, 2006
>>scanf("%c,%d,%d,%d",&status,&defect,&chnum,&w_cond);
The problem is here: replace the commas with spaces.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,600
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 462
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: c home work

 
0
  #3
Nov 27th, 2006
Also MasterBlast, use code tags to post your code since it makes the code easier to read as well as the formatting is maintained.

Read the forum announcements.
I don't accept change; I don't deserve to live.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 2
Reputation: MasterBlast is an unknown quantity at this point 
Solved Threads: 0
MasterBlast MasterBlast is offline Offline
Newbie Poster

Re: c home work

 
0
  #4
Nov 27th, 2006
thank you Ancient Dragon it worked well
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC