Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 17-06-2007, 07:17 AM   #1 (permalink)
Apprentice
 
hrushij's Avatar
 
Join Date: Nov 2006
Posts: 76
Exclamation C programming problem

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..???
__________________
HHJobanputra
hrushij is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 17-06-2007, 07:30 AM   #2 (permalink)
Wise Old Crow
 
blueshift's Avatar
 
Join Date: Apr 2005
Location: Inside the Pixel
Posts: 1,227
Default Re: C programming problem

where is the program?
__________________
http://twitter.com/blueshift155
blueshift is offline  
Old 17-06-2007, 09:26 AM   #3 (permalink)
Alpha Geek
 
ashfame's Avatar
 
Join Date: Mar 2006
Location: Delhi / Jaipur
Posts: 761
Default Re: C programming problem

pl describe ur problem
__________________
My RIG: C2D 2.0Ghz + Intel965 Mobo + OCZ Matched Pair 2X1GB DDR2 800Mhz + LG L226WTQ 22" LCD + CM 500W PSU + Palit HD 4850 512GDDR3
HOMEPAGE : http://www.ashfame.com | BLOG : http://blog.ashfame.com
ashfame is offline  
Old 17-06-2007, 11:37 AM   #4 (permalink)
In The Zone
 
::cyborg::'s Avatar
 
Join Date: Oct 2005
Location: NEW DELHI
Posts: 436
Default Re: C programming problem

use &d and use %c

in the scanf function
__________________
- KEEP SMILING
::cyborg:: is offline  
Old 17-06-2007, 12:24 PM   #5 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
Default Re: C programming problem

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.
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 17-06-2007, 02:08 PM   #6 (permalink)
C# Be Sharp !
 
Zeeshan Quireshi's Avatar
 
Join Date: Jun 2006
Location: Toronto
Posts: 1,805
Default Re: C programming problem

Quote:
Originally Posted by hrushij
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
__________________
There are 10 types of people in the world: those who understand binary and those who do not.
Zeeshan Quireshi is offline  
Old 17-06-2007, 08:06 PM   #7 (permalink)
God of Mistakes...
 
Garbage's Avatar
 
Join Date: Dec 2005
Location: Pune, Maharashtra
Posts: 1,905
Cool Re: C programming problem

Quote:
Originally Posted by Zeeshan Quireshi
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.
__________________
Registered Linux User #468778
----------------------------------
http://twitter.com/_Garbage_
Garbage is offline  
Old 18-06-2007, 10:32 AM   #8 (permalink)
Wise Old Owl
 
piyush gupta's Avatar
 
Join Date: Sep 2005
Location: never land
Posts: 1,284
Default Re: C programming problem

Where is your program?
piyush gupta is offline  
Old 19-06-2007, 03:20 PM   #9 (permalink)
Alpha Geek
 
harryneopotter's Avatar
 
Join Date: Feb 2007
Posts: 935
Default Re: C programming problem

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 ..........
harryneopotter is online now  
Old 20-06-2007, 05:53 AM   #10 (permalink)
Apprentice
 
hrushij's Avatar
 
Join Date: Nov 2006
Posts: 76
Default Re: C programming problem

ok got it.....thx guys
__________________
HHJobanputra
hrushij is offline  
Old 21-06-2007, 01:24 PM   #11 (permalink)
In The Zone
 
Join Date: Oct 2004
Posts: 437
Default Re: C programming problem

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
http://visitguru.com/forum/viewforum.php?f=23

have a look
__________________
be who u r :
Saharika is offline  
Old 23-06-2007, 07:20 AM   #12 (permalink)
Apprentice
 
hrushij's Avatar
 
Join Date: Nov 2006
Posts: 76
Default Re: C programming problem

thank you.....my friend
__________________
HHJobanputra
hrushij is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unix(shell Programming) and TCP/IP programming tutorials Matrix Programming 4 08-04-2008 09:54 PM
programming............ Mohnishgs Programming 18 18-05-2007 07:57 PM
Need sme help in programming dashang Tutorials 2 12-05-2007 10:56 PM
'Assembly Language Programming' Problem a_to_z123 Programming 5 03-12-2005 02:51 PM
Programming Help demoninside Programming 4 10-04-2005 11:30 PM


All times are GMT +5.5. The time now is 05:14 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2