Problem - A simple C program using Structures
Sorry friends for starting a new thread for such a simple problem.
I have a very simple program which is not running fine as expected. I know there's some mistake from my side but where? Code:
#include<stdio.h> Code:
Any suggesttions about where I am doing it wrong? |
The problem is that when you tell scanf to read the numbers it gets all the digits but leaves the newline ('\n') at the end of the line on the stream. So when you try to read a character next time, it just reads the newline character. scanf is messed up like that
|
Oh thanks. So, how to overcome this problem. I compiled this program on one of my friends windows machine by adding a line
Code:
fflush (stdin); |
Here is a useful information about Linux programming.
http://www.gnu.org/software/libc/man...ode/index.html |
Yea the fflush works diffrent in linux then it does in dos. Not sure why this happens but i suspect its how linux buffers the data and how dos buffers the data.
|
I found out why.
here is the excerpt from Cprogramming.com Quote:
|
Quote:
|
All times are GMT -5. The time now is 06:06 PM. |