disturbing problem with PRINTF() !!

hello everybody,
here is my problem:
________________________________________
#include <stdio.h>

int main()
{
int i=10;
printf("value is %i",i);
return 0;
}
_________________________________________

when i compile and execute, nothing appears on screen!!
but if i replace the printf line with this one:
printf("value is %i\n",i); // i just added a \n
then i can see the line displayed on my screen.
ok, that's allright, but what if i want to display something _without_ the \n ?

someone told me it was a classic buffer problem and adviced me to use fflush()
but when i write:
printf("value is %i",i); fflush(stdout);
nothing happens. i also tried to put fflush(stdout) before the printf, because i don't know how to use this function correcly, but nothing happened.

can someone explain me what's the matter?!!
im using Linux Mandrake 8.0
thanks :slight_smile:

My guess is that your shell is overwriting the data with its prompt. Try this:
printf("value is %d", i);
fflush(stdout);
sleep(10);

:smiley:

that's great, you were right!

nice guess. now i finally understand what's happening, thank you!

:cool:
anyway im disapointed with this bash shell...
is there a way to set the bash so that it doesn't overwrite the data?