[Fwd: Re: printf without '\n']
Quoted 30 lines · Ricardo Catalinas Jimenez
Newbie simple question:
With a code like this:
.section .data
MSG:.ascii "Hello\0".section .text
.globl_start_start:
pushl %ebp
movl %esp, %ebppushl $MSG
call printfmovl %ebp, %esp
popl %ebpmovl $1, %eax
xorl %ebx, %ebx
int $0x80I compiled it with:
as code.s -o code.o; ld --dynamic-linker/lib/ld-linux.so.2-lc \
test.o -o testWith that ascii string, nothing is printed but when I use "Hello\n\0" it works fine.
Quoted 11 lines
What is the reason for not printing the string if there isn't a '\n' in it?
I something related with the buffered (by lines) IO?
Why with a C program it does not happend.
Thanks in advance.
You should flush stdio(3) buffers before exiting. Try with fflush(3).
This program exits with the _exit(2) system call without flushing buffers nor deinitializing C standard libraries. If you try to exit with exit(3) libc it will work.
You can the behaviour of your current program with this simple C program:
main()
{
printf("hello");
_exit(0);
}
If you change _exit(2) by exit(3) it will work...
Luck,
Gerardo García Peña