   Writing to files in win32?
  I'm just learning win32, but i've found that the lack of having a terminal to output little test messages amkes it hard for a begginer like me to play with lines and tweak them and have it display test messages. I was looking for a way to write to a simple text file messages, and use that like a terminal. I also figured this would be a usefull thing to know for the futute. So, in short, does anyone know how to write a simple string to a text file in a win32 program?Meow.   
  You can use AllocConsole( ) and FreeConsole( ) in your program.  This will allocate and show console window that you can use to print to.  You will have to redefine the standard output if you want to use printf or std::cout.   ;  You can also use the ANSI c file functions (fopen, etc.) or the c++ file stream class to write to a file.If you want to write text to the output window of Visual Studio (if you're using that) you can use the function OutputDebugString. This will only work in DEBUG builds though.   ;  i tried the C++ fstream, but when ever i try to declare a ofstream file it gives me an error =/The program I'm playing with right now is something of a key logger i suppose. Nothing fancy at all, i'm just practicing with windows messages, and i'm trying to make something that will read when you press a key, put it's value into a string, then write the string to a file. So i could do soemthing like run it, type "Hello World", then have it have Hello World in a tct document.Mreow.   ;  Add this to your code.  This will allow you to use printf and std::cout.#include <io.h>AllocConsole();long lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);  int hConHandle = _open_osfhandle(lStdHandle, 0X4000);  FILE* fp = _fdopen( hConHandle, "w" );  *stdout = *fp;  setvbuf( stdout, NULL, _IONBF, 0 );;  Hey there! I learned win32 about a year or two ago and I now program in it professionally. I would like to offer you some awesome advice that I hope is relevant, and that I really wished someone would have taught me when I was just starting out. First, only use an API (such as win32) for what it is useful for. Although it does offer the ability to write to consoles etc, the real point of using win32 is to write Windows Programs. Now I know that if I use ISO/ANSI C++, I can accomplish ANYTHING I want! However, it does not have access to network sockets and graphical drawing routines for Windows, Mac, and Linux.So. Enough of my babeling...here it is: Use as much standardized ISO/ANSI C++ as possible in all of your code. Only use interfaces and libraries for PROPRIETARY systems where ABSOLUTELY necessary! Here are a few reasons for this:1. ANSI/ISO C++ is faster.2. Win32, Java, etc all use these API's underneath everything anyway.3. You will have fewer parts of your application which will not work on other systems.For example, the Java graphics API is entirely written in OpenGL. So my question then is this: Why do I need Java for games? ;)Here is a snipet of code that should get you moving in your log file quest:#include <fstream>#include <iostream>using namespace std;ofstream logFile("myAppsLogFile.txt", ios::out);    logFile << someErrorDumpVariable << "some hard coded message";That's about it ;). Happy coding!   ;  I'll play around with that^^I Also tried using he C fopen() and fprintf() functions and they seem to be working ok. Is there any advantage or downside to this method as compared to the fstream one?Thanks^^Mreow.   