Page 1 of 1

help, C problem

Posted: Fri Feb 20, 2009 7:52 am
by Ratstail91
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);
}

...

Re: help, C problem

Posted: Fri Feb 20, 2009 10:20 am
by wtetzner
Could you post your main() function too? Also, you need to return an int from wait(), or change it to void wait().

Re: help, C problem

Posted: Fri Feb 20, 2009 12:16 pm
by MarauderIIC
http://www1.coe.neu.edu/~emelas/char.html might help you. In short, try changing your call to

Code: Select all

scanf("%c%*c", &n);
since you're reading a character.

Edit: Fixed, thanks sparda.

Re: help, C problem

Posted: Fri Feb 20, 2009 12:23 pm
by sparda
you use scanf("%c%*c", &n);

not scanf("%c%*c", n);

*Fixed*

Re: help, C problem

Posted: Tue Feb 24, 2009 4:40 am
by Ratstail91
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!