DIGIT-ARC read-only archive · snapshot: July 23, 2026

C programming problem

12 posts · originally from https://geek.digit.in/community/threads/c-programming-problem.60607/

hrushij
hrushij Original post #1
Jun 17, 2007 at 7:17 AM
I have a prablem with a program...
when i scan a character first then it will be scaned....
but when i want to scan a integer and then charcter.....
it will not be accepted and program ends...
I don't want to use any kind of 'flush' like flushall,fflush....etc.
what is the problem..???
blueshift
Jun 17, 2007 at 7:30 AM
where is the program?
ashfame
ashfame #3
Jun 17, 2007 at 9:26 AM
pl describe ur problem
::cyborg::
Jun 17, 2007 at 11:37 AM
use &d and use %c

in the scanf function
Garbage
Garbage #5
Jun 17, 2007 at 12:24 PM
I think it's bcoz of '\n' character remains in buffer.
If u want to override this problem then u have to flush the buffer anyhow.
Zeeshan Quireshi
Jun 17, 2007 at 2:08 PM
hrushij said:
I have a prablem with a program...
when i scan a character first then it will be scaned....
but when i want to scan a integer and then charcter.....
it will not be accepted and program ends...
I don't want to use any kind of 'flush' like flushall,fflush....etc.
what is the problem..???
yups , u have the "/n" character in still left in your buffer which gives the illusion that the input statement is being skipped .

to solve this use cin.ignore() function after every input to clear the newline character left in the buffer :)
Garbage
Garbage #7
Jun 17, 2007 at 8:06 PM
Zeeshan Quireshi said:
yups , u have the "/n" character in still left in your buffer which gives the illusion that the input statement is being skipped .
dude, it's '\n' & NOT '/n'. It's an escape sequence.
piyush gupta
Jun 18, 2007 at 10:32 AM
Where is your program?
harryneopotter
Jun 19, 2007 at 3:20 PM
if u r accepting single characters as input .. then u can use getch() ir getche() in ur prog ... but if u want to enter integers (mean more than 1 char ) to skip the "\n" u have to use flushing ..........
hrushij
hrushij #10
Jun 20, 2007 at 5:53 AM
ok got it.....thx guys
S
Saharika #11
Jun 21, 2007 at 1:24 PM
for any kind of c programming codes i have found this site very helpful for academic purpose...it is just starting but i can see very good C programming library already...
i hope it is helpful for acedemic purpose
*visitguru.com/forum/viewforum.php?f=23

have a look
hrushij
hrushij #12
Jun 23, 2007 at 7:20 AM
thank you.....my friend