I have a bug with fgets that I can't figure out
The code is located at: C code - 79 lines - codepad
The problem I'm having is in askUserForAmount();
http://i.imgur.com/Ic4XcXJ.png is my output.
I use "Title here" for title.
I use "Description Here" for description.
I use the example for numeric amount (12.5)
Then when I hit enter, it prints out "Known Quantity Types include:"
and "Please enter the quantity type for this item:"
And instead of waiting for my input, it goes onto display my qtype incorrectly as 5, and then display my amount and qtype.
Amount is apparently "12." and qtype is "5".
Why is this happening? What's in the 12.5 string that breaks this? If I do 12 instead of 12.5, it asks me for the quantity type correctly. BUT, if I have any spaces in quantity type (ex: fl oz), the fgets treats the space as a new line(?) and drops the oz.
I must be doing something wrong, but can't figure out what. Thank you for any help.
Output with broken quantity type http://i.imgur.com/Xvs52Wn.png