Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

A neat counter

Display your little helpful snippets of code that may help us all get something done

A neat counter

Postby glinka57 on Mon Jul 13, 2009 5:21 pm

Code: Select all
#include "stdafx.h"
#include <iostream>
using namespace std;

#include <windows.h> 


/*
                      windows.h
- I needed the COORD class which is found in this header

- I needed the Sleep(int); function which is defined in this header
  lol dont forget that capital S on Sleep, sheesh
  the int is a number of milliseconds; so Sleep(1000); pauses the console for 1 second

- I needed the function:
  SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
  which is defined in this header
*/



void gotoxy ( short x, short y )
{
  COORD coord = {x, y};
  SetConsoleCursorPosition ( GetStdHandle ( STD_OUTPUT_HANDLE ), coord );
}
//This func allows you to spicify the cursor's position
// check http://cpptutorials.freeforums.org/select-character-insertion-point-t213.html for the details
// about the gotoxy(); function
 




void main()               
{
   for(int x=0;x<x+1;x++)
   {
      gotoxy(40,10);
      cout<<x<<"\n";
      Sleep(85);
   }
}
User avatar
glinka57
 
Posts: 195
Joined: Fri Feb 27, 2009 7:32 pm

Return to Snippets

Who is online

Users browsing this forum: No registered users and 0 guests