Thanks Paul for this information.
I was used to use fflush on stdin as fflush(stdin) on windows and this work
fine for me and this may be because windows support fflush on stdin and this
could be the reason why i was getting unexpected result when i was using my
own input stream.
So, Paul can you tell me how to flush input stream like:
#define BUFFER_SIZE_8 8
int main()
{
char inBuffer[BUFFER_SIZE_8], inBuffer1[BUFFER_SIZE_8];
fgets(inBuffer,BUFFER_SIZE_8,stdin);
fgets(inBuffer,BUFFER_SIZE_8,stdin);
printf("%s\n%s\n",inBuffer,inBuffer1);
return 0;
}
Now during my first input i enter following value :
"vishalthakurthakurvishal"
First fgets will read first 8 charecters and rest will remain in stdin
stream
2nd fgets will autometically read from stdin as some data is existing their.
How i can made 2nd fgets interactive means how can i flush stdin now.
Thanks & Regards
Vishal Thakur
On 20 Mar 2007 09:39:58 -0700, Paul Herring <[EMAIL PROTECTED]> wrote:
>
> On 20 Mar 2007 08:52:51 -0700, vishal thakur <[EMAIL
> PROTECTED]<lahsiv.vishal%40gmail.com>>
> wrote:
> > On 3/20/07, Paul Herring <[EMAIL PROTECTED]<pauljherring%40gmail.com>>
> wrote:
> > > On 19 Mar 2007 20:38:07 -0700, vishal thakur <[EMAIL
> > > PROTECTED]<lahsiv.vishal%40gmail.com>
> <lahsiv.vishal%40gmail.com>>
> > > wrote:
> > > > I think flushing buffer (fflush(stdin), if using stdin as your
> stream)
> > > > will
> > > > solve your problem, but flush will work in case of stdin but it will
> not
> > > > give desired output for file stream
> > >
> > > fflush() is not required to work with stdin (or with cin.)
> >
> > Can you clear little bit on this : " fflush() is not required to work
> with
> > stdin (or with cin.)"
>
> fflush() is for flushing output streams, not input streams. (Your
> compiler might allow it on input streams, but not every compiler will
> support it.) For example:
>
> http://www.hmug.org/man/3/fflush.php
>
> makes no mention of input streams, only output streams.
>
> --
> PJH
> Aio, quantitas magna frumentorum est
>
>
--
Regards
Vishal Thakur
+919871892410
[Non-text portions of this message have been removed]