Bash overwrites data on screen!!

hi everybody,
when i run and compile this:

printf("test"); fflush(stdout);

nothing appears on screen.
if i try this:
___________________________________

printf("test"); fflush(stdout); sleep(10);

___________________________________
then i can see the output "test"... for 10 secondes, and after that the new line of shell overwrites the line of data.
this is:
___________________________________

#./myprog
test
___________________________________
for 10 secondes and then:

___________________________________
#./myprog
#
____________________________________
ive been told that this was beacause the shell overwrites the data.
does anybody knows how to prevent my bash to overwrite my progs?!!!
thanks.

Would adding a \n for newline work for you? Check the format man page (Section 5) which was referenced in the printf man page.

yes, that's right, if i just write:

printf("test\n");

then it appears properly on screen.
but what if i don't want to use \n ?
and also, the new bash line should appear next to my data, but should not
overwrite it! i would like to know why...

Because that is the default - I found the following at
http://www.gnu.org/manual/bash-2.02/html_mono/bashref.html

PS1 The primary prompt string. The default value is `\s-\v\$ '.

thank you very much for answering and helping me!

that's right, the problem comes from the variable PS1.

in fact when i use the csh shell instead of bash my problem disappears.

but i want to keep my bash!

so i have to modify PS1.

my default PS1 is:

[\u@\h \W]\$

this one or the other default keeps the problem.

i read the "man bash" about PS1 and the only solution i saw is to put the option \n

in PS1, this is the new line special character. it solves my problem: i can see my datas.

but: now each time i press return i see a blank line!!

this is not really annoying, but i still don't know exactly which variable or stuff causes the problem.

because now i see:

____________________

[localhost]$./myprog

test

[localhost]$

____________________

and i should see:

____________________

[localhost]$./myprog

test[localhost]$

____________________

this last result is what i obtain with csh for instance.

see you

:wink: