Hi, found this small lite-c script, i created a while ago, on my hdd. Thought it might be helpfull for others:

Click to reveal..
Code:
#ifndef Console_c
	#define Console_c
	#include<windows.h>;

	long WINAPI WriteConsole(int Handle, char* Buffer, int CharsToWrite, int* CharsWritten, int reserved);
	long WINAPI CreateConsoleScreenBuffer(
	long dwDesiredAccess,
	long dwShareMode,
	long *lpSecurityAttributes,
	long dwFlags,
	long lpScreenBufferData
	);

	long WINAPI SetConsoleActiveScreenBuffer(
	long hConsoleOutput
	);

	long GConsoleBuffer;

	void printf(char* AText)
	{
		WriteConsole(GConsoleBuffer, AText, str_len(AText), NULL, 0);	
	}

	void _main();

	void main()
	{
		AllocConsole();
		GConsoleBuffer = CreateConsoleScreenBuffer(GENERIC_WRITE, FILE_SHARE_READ, 0, CONSOLE_TEXTMODE_BUFFER, 0);
		SetConsoleActiveScreenBuffer(GConsoleBuffer);	
		_main();	
	}

	#define main _main
#endif



add this file as the FIRST one. Its going to register the console, and redeclaring printf (only for one parameteer though)

you are wondering about my void main()?

don't worry. the
Code:
void _main()


predeclaration before and the
Code:
#define main _main


at the end allow me to "hook" you'r main. My main is executed before you'r main(which is required to get a working printf in you'r main, as startup functions are executed AFTER main -.-)

Last edited by Rackscha; 01/24/13 17:23.

MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development