c stdout print without new line?
i want to print "CLIENT>" on stdout in c, without new line.
printf("CLIENT>"); does not print enything. how do i solve this?int main (){
printf("CLIENT>");
}
Try fflush(stdout);
after your printf
.
You can also investigate setvbuf
if you find yourself calling fflush
frequently and want to avoid having to call it altogether. Be aware that if you are writing lots of output to standard output then there will probably be a performance penalty to using setvbuf
.
Call fflush
after printf()
:
int main (){
printf("CLIENT>");
fflush( stdout );
}
On some compilers/runtime libraries (usually the older ones) you have to call fflush to have the data physically written:
#include <stdio.h>
int main( void )
{
printf("CLIENT>");
fflush(stdout);
return 0;
}
If the data has newline in the end, usually fflush
isn't needed - even on the older systems.
精彩评论