Ok so we were given a homework assignment and I am having trouble with it. We are supposed to minipulate a box in the center of the screen with the input given by a user. The input values given are height and width. How can I create a box in the center of the screen with only two values?

this is what I got so far:

#include "DarkGDK.h"

void displayMessage()
{
	int firstNum, secondNum;

	dbPrint("Enter the patterns width:");
	firstNum = atoi(dbInput());

	dbPrint("Enter the patterns height:");
	secondNum = atoi(dbInput());

}

void DarkGDK()
{
	DWORD white = dbRGB(255,250,250);
	DWORD black = dbRGB(0,0,0);

	displayMessage();
	
	dbClear(255,250,250);

	dbInk(black, white);

	dbLine(0,0,640,480);
	dbLine(640,0,0,480);
	dbLine(320,0,320,480);
	dbLine(0,240,640,240);


	dbInk(black, black);
	dbBox(int firstNum,int secondNum);


	dbWaitKey();

}

I keep getting error messages:
error C2059: syntax error : ')'
error C2661: 'dbBox' : no overloaded function takes 0 arguments
error C2144: syntax error : 'int' should be preceded by ')'

Edited 6 Years Ago by MindTrixz: n/a

Look at line 33 - is this the correct way to call a function? See line 24 for a good example...

But you have a second problem. Look at where "firstNum" and "secondNum" are declared (in the function "displayMessage"). These will not be visible in your main() function. You either need to define them in main, then pass them to the displayMessage function, or make them global.

Edited 6 Years Ago by mcriscolo: n/a

We are supposed to minipulate a box in the center of the screen with the input given by a user. The input values given are height and width. How can I create a box in the center of the screen with only two values?

If the two values provided are the dimensions of the box then you would also need to know the dimensions of the screen. Once you have the screen dimensions it's a basic calculation. The centre point of the box should be the centre of the screen.

This article has been dead for over six months. Start a new discussion instead.