NASM - The Netwide Assembler
NASM Forum => Programming with NASM => Topic started by: mene mene tekel on March 05, 2007, 07:40:41 PM
-
Hi,
I compiled a win32 console progamme and link it using
alink -oPE -subsys con ... -o example.exe
Running the program prints to the console (using printf from crtdll.dll), but trying an output redirection to a file like
example.exe 1>OutputFile.txt
the console outputs are gone, a file named OutputFile.txt is created, BUT nothing is written in!
Anybody an idea where the problem is?
Thanks!
PS: working in Microsoft Windows XP [Version 5.1.2600]
-
I'm only certified for beginner questions, but I'll take a flying wild-asmed guess...
There's an issue about "flushing the buffer" - "printf" doesn't really output anything until you "flush the buffer". Normally, this would happen with a newline sequence, or when your program exits. You can also "fflush(stdout)". If your string doesn't end with "13, 10, 0", this might cause different behavior depending on whether it's redirected or not.
Just a guess - it could also be a "Microsoft problem".
Best,
Frank
-
Hi Frank,
You are right! I implemented an additinal _fflushall() and it works!
Amazing is, that I knew about this issue but because my string ends with 13,10,0 I decided flushing cannot be the reason - and again, I learned something new ;-)
Thanks,
Martin
-
Me too! (sometimes you need it even *with* a newline!) Thanks for the confirmation, Martin!
Best,
Frank