[LCP]printf Question
sasidhar p
psasidhar at hotmail.com
Thu Aug 30 17:08:26 UTC 2001
Hi,
Can somebody explain me this behaviour, I am all confused....
main()
{
while(1)
{
printf("Hi\n");
getchar();
}
}
Out put :
[psasi at jldev 2]$ ./a.out
Hi
a
Hi
Hi
b
Hi
Hi
c
Hi
Hi
d
Hi
Hi
[psasi at jldev 2]$
I am using gcc on Linux 2.2.14
why is the "Hi" getting printed twice...
I tried the following variants, but the o/p pattern is same...
#include <stdio.h>
#include <unistd.h>
main()
{
char buf[]="Hi\n";
while (1)
{
write(1,buf,3); /* I tried writing to fd 2 also*/
getchar();
}
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
More information about the linuxCprogramming
mailing list