<?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>Visual C++ Tips &#187; time_t</title>
	<atom:link href="http://weseetips.com/tag/time_t/feed/" rel="self" type="application/rss+xml" />
	<link>http://weseetips.com</link>
	<description>Gold mine of Visual C++ tricks!</description>
	<lastBuildDate>Thu, 11 Mar 2010 09:09:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>gotoxy() function in Visual C++?</title>
		<link>http://weseetips.com/2009/03/01/gotoxy-function-in-visual-c/</link>
		<comments>http://weseetips.com/2009/03/01/gotoxy-function-in-visual-c/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 18:39:49 +0000</pubDate>
		<dc:creator>Jijo Raj</dc:creator>
				<category><![CDATA[Codeproject]]></category>
		<category><![CDATA[Visual C++]]></category>
		<category><![CDATA[C++ gotoxy()]]></category>
		<category><![CDATA[COORD]]></category>
		<category><![CDATA[ctime]]></category>
		<category><![CDATA[GetStdHandle()]]></category>
		<category><![CDATA[gotoxy()]]></category>
		<category><![CDATA[gotoxy() function]]></category>
		<category><![CDATA[SetConsoleCursorPosition()]]></category>
		<category><![CDATA[time()]]></category>
		<category><![CDATA[time_t]]></category>
		<category><![CDATA[turbo C++ gotoxy]]></category>
		<category><![CDATA[visual C++ gotoxy]]></category>

		<guid isPermaLink="false">http://weseetips.com/?p=874</guid>
		<description><![CDATA[I often feel nostalgic about the gotoxy() function in old Turbo C++. The gotoxy() is used to &#8220;jump&#8221; to any point of the console screen. I used that function to create nice menu effects. But unfortunately in visual C++, gotoxy() is not available. But is there any other api which can be used instead of [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-medium wp-image-11" title="Icon Description" src="http://weseetips.files.wordpress.com/2008/03/icon_description.jpg?w=166" alt="" width="166" height="32" /><br />
I often <span style="color:#0000ff;">feel nostalgic</span> about the <span style="color:#0000ff;">gotoxy() function in old Turbo C++</span>. The gotoxy() is used to <strong>&#8220;jump&#8221;</strong> to any point of the console screen. I used that function to create nice menu effects. But unfortunately <span style="color:#0000ff;">in visual C++, gotoxy() is not available.</span> But is there any other api which can be used instead of gotoxy()?</p>
<p><img class="alignnone size-full wp-image-875" title="gotoxy1" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/03/gotoxy1.jpg" alt="gotoxy1" width="510" height="429" /></p>
<p><img class="alignnone size-medium wp-image-12" title="Icon How Can I Do It?" src="http://weseetips.files.wordpress.com/2008/03/icon_howcanidoit.jpg?w=220" alt="" width="220" height="32" /><br />
You can use <span style="color:#0000ff;">SetConsoleCursorPosition()</span>. Check out the following sample program. It reads an integer in loop and prints the time in the right hand corner of console. Just a demonstration of Visual C++&#8217;s gotoxy().</p>
<p><img class="alignnone size-full wp-image-876" title="gotoxy2" src="http://siteground205.com/~weseetip/wp-content/uploads/2009/03/gotoxy2.jpg" alt="gotoxy2" width="509" height="292" /></p>
<pre>#include "iostream"
#include "time.h"
#include "windows.h"

using namespace std;

// Set current cursor position.
void GotoXY( HANDLE StdOut, SHORT x, SHORT y )
{
    // Set the cursor position.
    COORD Cord;
    Cord.X = x;
    Cord.Y = y;
    SetConsoleCursorPosition( StdOut, Cord );
}

// Print time at the upper right corner of console.
void PrintTime()
{
    // Get handle to console output buffer.
    HANDLE hStdout = GetStdHandle( STD_OUTPUT_HANDLE );

    // Get current screen information.
    CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo = { 0 };
    GetConsoleScreenBufferInfo( hStdout, &amp;ScreenBufferInfo );

    // Set the cursor position to upper-right of console.
    GotoXY( hStdout, 50, 0 );

    // Get time and display it.
    time_t tim=time(NULL);
    char *s=ctime(&amp;tim);
    cout &lt;&lt; s;

    // Reset cursor back to position.
    GotoXY( hStdout,
            ScreenBufferInfo.dwCursorPosition.X,
            ScreenBufferInfo.dwCursorPosition.Y );
}

void main(int argc, char* argv[])
{
    // Just to provide enough space.
    cout &lt;&lt; endl &lt;&lt; endl;

    while( true )
    {
        // Print the time.
        PrintTime();

        // Read a value.
        int a;
        cout &lt;&lt; "Enter number: ";
        cin &gt;&gt; a;
    }
}</pre>
<p><img class="alignnone size-medium wp-image-18" title="Icon Note" src="http://weseetips.files.wordpress.com/2008/03/icon_note.jpg?w=94" alt="" width="94" height="32" /><br />
Yes! After a short break, <span style="color:#0000ff;">I&#8217;m back</span>. <img src='http://weseetips.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  You&#8217;ll soon have a happy news from me, within a week. <img src='http://weseetips.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Keep watching.</p>
<p><img class="alignnone size-medium wp-image-51" title="beginnerseries" src="http://weseetips.files.wordpress.com/2008/03/beginnerseries.jpg?w=215" alt="" width="215" height="32" /><br />
Targeted Audience &#8211; Beginners.</p>
]]></content:encoded>
			<wfw:commentRss>http://weseetips.com/2009/03/01/gotoxy-function-in-visual-c/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

