Programador

Páginas: 2 (362 palabras) Publicado: 22 de mayo de 2012
// crt_BEGTHRD.C
// compile with: /MT /D "_X86_" /c
// processor: x86

#include "stdafx.h"

#include
#include /* _beginthread, _endthread */
#include
#include
#include

voidBounce( void *ch );
void CheckKey( void *dummy );

/* GetRandom returns a random integer between min and max. */
#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))

BOOLrepeat = TRUE; /* Global repeat flag and video variable */
HANDLE hStdOut; /* Handle for console window */
CONSOLE_SCREEN_BUFFER_INFO csbi; /* Console information structure */
//int_threadid;

int main()
{
CHAR ch = 'A';

hStdOut = GetStdHandle( STD_OUTPUT_HANDLE );

/* Get display screen's text row and column information. */
GetConsoleScreenBufferInfo(hStdOut, &csbi );

/* Launch CheckKey thread to check for terminating keystroke. */
_beginthread( CheckKey, 0, NULL );

/* Loop until CheckKey terminates program. */
while(repeat )
{
/* On first loops, launch character threads. */
_beginthread( Bounce, 0, (void *) (ch++) );

/* Wait one second between loops. */
Sleep( 1000L );}
}

/* CheckKey - Thread to wait for a keystroke, then clear repeat flag. */
void CheckKey( void *dummy )
{
_getch();
repeat = 0; /* _endthread implied */
_endthread();
}/* Bounce - Thread to create and and control a colored letter that moves
* around on the screen.
*
* Params: ch - the letter to be moved
*/
void Bounce( void *ch )
{
/* Generate letterand color attribute from thread argument. */
char blankcell = 0x20;
char blockcell = (char) ch;
BOOL first = TRUE;
COORD oldcoord, newcoord;
DWORD result;/* Seed random number generator and get initial location. */
srand( _threadid );
newcoord.X = GetRandom( 0, csbi.dwSize.X - 1 );
// newcoord.Y = GetRandom( 0, csbi.dwSize.Y - 1 );...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Programa
  • Program
  • Un Programa
  • Programas
  • Programas
  • Programa
  • Programador
  • Program

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS