Welcome to the wonders of 'c' I bet you the whitespace is tripping you up.
iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
Stop using crappy input techniques, and you'll likely discover that the problems you are currently experiencing will vanish.
gets is your first mistake. http://www.cprogramming.com/tips/showTip.php?tip=3&count=30&page=1
scanf leaves a trailing newline in the input buffer. This is bad because other functions will grab the newline left behind, and input functions will be skipped, etc, etc. If you need to grab a single character from the input buffer, use getchar() , but make sure you get rid of the newline after you retrieve the character. Here's a better explanation: http://www.gidnetwork.com/b-60.html
The proper way to do input is to use functions such as fgets which grab an entire line. Of course, then you end up with a newline in the string, but this is easily removed. Here is a good input tutorial which you should read to learn more about this: http://www.daniweb.com/tutorials/tutorial45806.html
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
How come you aren't assigning the return value of getchar() to a variable? I'd say there's a pretty low chance of the results of the function magically jumping into your 'mood' variable.
And post your updated code so that we can see what else is going on.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
twhich bit did i screw up? should there be an &mood in the ()?
i used that tutorial before and same problem still..
if you are talking about the switch(mood) you don't need to write the
& operator there.
Did you take a look at the links that Joeprogrammer posted for you?.
They will help you to understand why is not working.
If you did. Could you post the changes you did to your code? That would help a lot.
Aia
Nearly a Posting Maven
2,392 posts since Dec 2006
Reputation Points: 2,224
Solved Threads: 218