Ok,trying to write a simple 2D game and the code below has been written by me in C++ in a Win32console project using visual studio 2003. The API is one designed by a tutor and is called HAPI

This part of the code should:
1. clear the screen to an arbitrary colour
2. generate random white pixels on the screen (so it is like a starry background)

However, as always nothing goes smoothly when im doing 'simple' programming.

Take a minute to look thru the code then see can you help me out with the problems below.....
__________________________________________________ ___
Code:
#include <HAPI_lib.h>
#include <stdlib.h>

typedef DWORD;

void clearScreen ( BYTE, BYTE, BYTE );
void setPixel ( BYTE *, int, int, int, BYTE, BYTE, BYTE );

void main()
{
     int screenWidth=400;
     int screenHeight=300;

     if (!HAPI_Initialise(&screenWidth,&screenHeight))
         return;

    BYTE red = 255;
	BYTE green = 255;
	BYTE blue = 0;
	int rand();

     while(HAPI_Update())
     { 
		clearScreen ( red, green, blue );
	 
		for(int i = 0; i < NumberOfStars; i++)
		{
			int x = rand() % screenWidth;
			int y = rand() % screenHeight;

			setPixel(x, y, white);
		}

	 }

   return;
}

void clearScreen (BYTE r, BYTE g, BYTE b )
{
	int screenWidth;
	int screenHeight;

	DWORD c = ( r << 24 | g << 16 | b << 8 );

	DWORD *pnter = ( DWORD * ) screen; 

	for ( int x = 0; x < screenWidth; x++ )
	{
		for ( int y = 0; y < screenHeight; y++ )
		{
			int offset = ( x+y*screenWidth )*4;
			memcpy ( pnter, &c, 4 );
			++pnter;
		}
	}
}

void setPixel ( BYTE *destination, int x, int y, BYTE r, BYTE g, BYTE b )
{
// setPixel function code
}
__________________________________________________ __

Problem 1
im unsure of how to write the function for randomly generating stars on screen. hence the prototype, the call and the function body have all been highlighted; done what i could but bit stumped on this.

Problem 2
when i compile the code it says 'screen' is an undeclared identifier.
problem is, what should it be declared as, and where?


help with either of the above would be great, and should there be any other errors or ways of improving the code dont hestitate to tell me. its the only way i'll learn!