Skip to main content
GameDev.net gamedev.net
🔒 Locked

VS2008 + SDL + stdout.txt stderr.txt

Started by nbertoa May 8, 2008 at 4:56 PM 7 replies 4.3k views
Original Post
nbertoa
nbertoa
Hi gamedev comunnity I configured Visual Studio 2008 to make SDL programs. I create Win32 Windows Application and I write an SDL program that has a line fprintf(stdout,.... and other line fprintf(stderr,.... When I execute the program, supposedly I have to look at the project folder a file called stdout.txt but it isn't. If I create Win32 Console Application I can see fprintf messages at console. How can I obtain stdout.txt and stderr.txt in my project folder?? Do I need to create Windows or Console application if I will work with SDL and OpenGL??? Thanks
Trenki
Trenki
The stdout.txt and stderr.txt files are only generated when I compile my windows SDL programs with MinGW (GCC). When compiling the same program with Visual Studio these files are not generated.

I don't know wheter there is a way to make Visual Studio compile the executable in a way that these files will be generated but normally you should not need these files anyway since there are most likely only used for debugging purposes in which case setting the subsystem to console while developing should be enough.
nhatkthanh
nhatkthanh
have you check the configuration folders? i.e project folder/debug or project folder/release
nbertoa
nbertoa
Yes, I checked all folders.
Do I need to create Win32 Windows Application or Win32 Console Application?
ICUP
ICUP
I believe for SDL it is always a Win32 console project.

I was having the same problem with fprintf. The files wouldn't generate. I just used C++'s file I/O to solve this problem.
nhatkthanh
nhatkthanh
Well stdout is by default redirecting output to the screen, if you have a console screen with your application then it will output it to that console. Or you can do I/O redirection and redirect it to a file like this on the command line. myProgram.exe > output.txt

Edit:

Or you can create your own to redirect the output to a file.

FILE *f = fopen("myfile.txt", "w");
fprintf(f, "%s", "hello world\n");
fclose(f);

[Edited by - nhatkthanh on May 9, 2008 1:37:14 PM]
nbertoa
nbertoa
Thanks I like stdout to Console, but Can I make a project SDL/OpenGL, with Win32 Console Application????

nbertoa
nbertoa
Thanks I like stdout to Console, but Can I make a project SDL/OpenGL, with Win32 Console Application????

nentwined
nentwined
Quote:
Original post by Nikko_Bertoa
Thanks I like stdout to Console, but Can I make a project SDL/OpenGL, with Win32 Console Application????


for simplicity's sake you might try opening your own "out" and "err" files, say in c:\err.txt and c:\out.txt ... for development that should "just work" and for something you release you don't really want it creating random files anyway.

I don't know/use visual studio (I use wxDev-C++)

(edit: just noticed nhatkthanh said pretty much the same thing ... and Trenki's answer seems best; I need to work on my "skimming comprehension" ;) )
kaolin fire- http://www.erif.org/- http://www.gudmagazine.com/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.