User forums > Using Code::Blocks
problem in a program
amit14:
actually I am facing a problem in creating a program. I have recently started learning c, and in the code
main()
{
char another;
int num;
do
{
printf("enter a number");
scan("%d", & num);
printf("want to enter another no. y/n");
scanf("%c", &another);
}while(another=='y');
}
the program ends without accepting the value of y or n
I changed the %c to %d, then it accepted the ASCII values of y and n(121 and 110), instead of the letters.
please help me solve this problem
stahta01:
Please read and follow the rules in the future.
http://forums.codeblocks.org/index.php/topic,9996.0.html
Please use code tags in the future
--- Code: ---scanf("%c", &another);
--- End code ---
The likely fix of your code; please read up on what a space does in front of "%c" in calling scanf.
--- Code: ---scanf(" %c", &another);
--- End code ---
Tim S.
amit14:
thanks
it is solved
well there is one more issue
can u explain me how to make a program for counting the no. of +ve, -ve, and zeroes I entered.
stahta01:
The line below is a hyperlink follow it!
http://catb.org/~esr/faqs/smart-questions.html
--- Quote ---Be sensitive in choosing where you ask your question. You are likely to be ignored, or written off as a loser, if you:
post your question to a forum where it's off topic
post a very elementary question to a forum where advanced technical questions are expected, or vice-versa
cross-post to too many different newsgroups
post a personal e-mail to somebody who is neither an acquaintance of yours nor personally responsible for solving your problem
--- End quote ---
You will likely be banned or this thread locked because you are still posting off topic questions!
Another link to the rules of this site; that, you seem to be unable to follow!
http://forums.codeblocks.org/index.php/topic,9996.0.html
Tim S.
amit14:
oh
sorry for this mistake
it means questions related to programming can't be asked on this forum.
then can you suggest me where can I ask these questions
can I inbox you or other users directly
Navigation
[0] Message Index
[#] Next page
Go to full version