<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>InsaneDevelopers &#187; allocconsole</title>
	<atom:link href="http://insanedevelopers.net/tag/allocconsole/feed/" rel="self" type="application/rss+xml" />
	<link>http://insanedevelopers.net</link>
	<description>My personal trash bin</description>
	<lastBuildDate>Mon, 29 Mar 2010 19:55:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating a console from a windows subsystem program</title>
		<link>http://insanedevelopers.net/2009/03/13/creating-a-console-from-a-windows-subsystem-program/</link>
		<comments>http://insanedevelopers.net/2009/03/13/creating-a-console-from-a-windows-subsystem-program/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 23:51:43 +0000</pubDate>
		<dc:creator>Alessandro</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[allocconsole]]></category>
		<category><![CDATA[console]]></category>

		<guid isPermaLink="false">http://insanedevelopers.net/?p=9</guid>
		<description><![CDATA[Sometimes, printing messages and dumping variables can be very handy for debugging purposes, but most of today's programs do not need and in fact do not open a console window.
The following is a way a console can be opened from a windows subsystem application.
// Open the console window
AllocConsole();

// Assign the stdin/stdout/stderr streams to the newly [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, printing messages and dumping variables can be very handy for debugging purposes, but most of today's programs do not need and in fact do not open a console window.</p>
<p>The following is a way a console can be opened from a windows subsystem application.</p>
<pre>// Open the console window
AllocConsole();

// Assign the stdin/stdout/stderr streams to the newly created console
_tfreopen_s(&amp;fpStdIn, _T("CONIN$"), _T("r"), stdin);
_tfreopen_s(&amp;fpStdOut, _T("CONOUT$"), _T("w"), stdout);
_tfreopen_s(&amp;fpStdErr, _T("CONOUT$"), _T("w"), stderr);</pre>
<p>Once opened and initialized, the console can be used just like you do in a normal text-based application. Note that you need to explicitly release both the console and the streams you opened.</p>
<pre>// Release the console
FreeConsole();

// Release the streams
fclose(stdin);
fclose(stdout);
fclose(stderr);</pre>
<p>It's a good idea to add this code inside an #ifdef statement, in order to remove this code (as well as the printf functions) from the release version.</p>
<p>Source code: <a href="http://www.InsaneDevelopers.net/sources/CreatingAConsole.zip">http://www.InsaneDevelopers.net/sources/CreatingAConsole.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://insanedevelopers.net/2009/03/13/creating-a-console-from-a-windows-subsystem-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
