Hello. I'm experienced in Game maker, but Im just starting to learn C.
my problem is, when I use a function, it works once, and then doesn't work again until i call main() and even then, other input fields don't work. it writes the string I put into the "continue" field into the "name"field.
I know this is confusing, but if anyone can help, it would be appreciated. here is the code.
int wait();
...
int wait()
{
char n;
printf("\ncontinue (y)?");
scanf("%d",n);
}
...
help, C problem
Moderator: Coders of Rage
- wtetzner
- Chaos Rift Regular
- Posts: 159
- Joined: Wed Feb 18, 2009 6:43 pm
- Current Project: waterbear, GBA game + editor
- Favorite Gaming Platforms: Game Boy Advance
- Programming Language of Choice: OCaml
- Location: TX
- Contact:
Re: help, C problem
Could you post your main() function too? Also, you need to return an int from wait(), or change it to void wait().
The novice realizes that the difference between code and data is trivial. The expert realizes that all code is data. And the true master realizes that all data is code.
- MarauderIIC
- Respected Programmer
- Posts: 3406
- Joined: Sat Jul 10, 2004 3:05 pm
- Location: Maryland, USA
Re: help, C problem
http://www1.coe.neu.edu/~emelas/char.html might help you. In short, try changing your call to
since you're reading a character.
Edit: Fixed, thanks sparda.
Code: Select all
scanf("%c%*c", &n);
Edit: Fixed, thanks sparda.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Re: help, C problem
you use scanf("%c%*c", &n);
not scanf("%c%*c", n);
*Fixed*
not scanf("%c%*c", n);
*Fixed*
- Ratstail91
- Chaos Rift Newbie
- Posts: 8
- Joined: Sun Feb 01, 2009 1:58 am
Re: help, C problem
Not a clue what anyone is talking about. however i think I figured it out. now... to write a program that actually does what i tell it too!