stderr.txt and stdout.txt files
I can't seem to figure out how to fix a problem with the stdout.txt and stderr.txt files. 1) Is their a way to have an option whether to use stderr.txt/stdout.txt or console? 2) Whenever I run a SDL prog, it puts everything into stdout.txt, (like it should), but the prog crashes. stdout.txt properties reveal it holds 4096 bytes (4 kilobytes) (on disk) If I add a printf("########################################"); the end 40 chars are removed, and if I look at stdout.txt, it shows 4096 bytes on disk. How do I fix it so it outputs more than 4096 bytes on disk. My program used to, and I can't think of anything that I changed to do this. Can you think of anything that can affect that? Thanks in advance
1) this should redirect them back to the console
freopen( "CON", "wt", stdout );
freopen( "CON", "wt", stderr );
freopen( "CON", "wt", stdout );
freopen( "CON", "wt", stderr );
Dolphins - The sharks of the sea.
1) Link with SDLmain_nostdio.lib instead of SDLmain.lib to prevent it from routing stdout/stderr to the text files.
2) Call fflush() on stdout and stderr after each time you write to them, or you can try setbuf(stdwhatever, NULL) to disable buffered output. I've never played with setbuf before, so I hope there won't be any complications :)
2) Call fflush() on stdout and stderr after each time you write to them, or you can try setbuf(stdwhatever, NULL) to disable buffered output. I've never played with setbuf before, so I hope there won't be any complications :)
Sorry, but that doesn't fix it
Before, the stdout.txt file did not have a limit on size
I did not need to have any such function called
Before, the stdout.txt file did not have a limit on size
I did not need to have any such function called
The fact that your file is showing up as 4096 bytes whether or not you change what is output to it a little is not an error. Unlike RAM, which is broken into blocks of one byte each, hard drive space is split in 4 KB blocks, and 4 KB = 4096 bytes. All files take up a minimum of 4 KB each on disk. In windows, if you open the properties tab for a file, there are two different sizes that it gives for the file -- the actual file size, which is labeled "Size:", and the amount of hard disk space the file is using, which is labeled "Size on disk:" and is always a multiple of 4096 bytes. You have been looking at the "Size on disk:". If you want to know how much actual data is in the file, check the thing above "Size on disk:". (This is all based on my XP machine, but as I recall the same information is available under 95, 98, etc.) None of this means that your program isn't still screwed up of course, but don't be freaked out by the size thing.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement