DaWei's Avatar, Join Date: Dec 2006
Team Leader
It was used to initialize the graphics drivers. Apparently the version was Borland's C/C++ 4.5. Whether or not that set of software is compatible withthe OP's platform is subject to question.
Resh's Avatar, Join Date: May 2007
Go4Expert Member
Well i am using is windows ME and the software is Microsoft Visual C++ 6.0 and unfortunately i dont understand some of what you said but thank you nevertheless
Resh's Avatar, Join Date: May 2007
Go4Expert Member
ok well when i remove the the conio.h, time.h and math.h from the program and insert the windows.h the errors that are coming up are sin and cos are undeclared identifiers what should i do about that??
aVague's Avatar, Join Date: May 2007
Go4Expert Member
brrrrrrrr,
sin and cos have prototypes in math.h , in windows.h mb too , you can search there
that ' s unimportant , you can include all libraly , and there ll be no errors
DaWei's Avatar, Join Date: Dec 2006
Team Leader
Okay, I'm going to recommend that you #include <cmath>. I have VC++6.0 also, and it is part of the include files. If you need time, use ctime. The reason for making the change is so that names that are part of the standard library live in a namespace called std. This reduces the probability of your choosing a label or identifier that clashes with the standard library names.

The drawback (though slight) is that you need to fully qualify names like "cout" as "std::cout". The alternative is to add a statement below the includes like: "using std::cout;" You can then use just "cout" (however, don't name something of your own, cout). You may see a recommendation to add a statement like "using namespace std;". This brings ALL the namespace in, and destroys the purpose of having the namespace in the first place. You can get away with it for examples and trivial programs, but it's better not to get into the habit.

It's unfortunate about the VC++ 6.0. It was actually written before the standard was adopted and is non-compliant in many respects, some important. I would suggest that you visit Microsoft and check out the requirements for VC2005 Express Edition. It's free, but I'm not sure if ME and your system's memory will be enough to handle it. If so, you will get a fairly compliant compiler. The debugger is every bit as good as the one in VC++ 6.0, one of the best available.

At any rate, since I have an old VC++ 6.0, I will be able to replicate any problems you encounter and suggest solutions.

If you absolutely require screen control such as that which was afforded by conio.h (and the conio.h that comes with Dev-Cpp as well), then I have Windows API specific code that can provide that. It just tosses portability to the winds. One does it in *nix with curses. That's a library, not what you say when you use it.
Resh's Avatar, Join Date: May 2007
Go4Expert Member
the #include<cmath> and #include<ctime> worked great to remove the errors for sin and cos however by chance is there one that i can include to remove moveto, lineto, setcolor, closegraph and initgraph where do those five live?????
Resh's Avatar, Join Date: May 2007
Go4Expert Member
also i dont quite understand how to input the "using std::cout;" becuase it removes the error LNK2001 but then it is creating errors on how i input it so that is giving me problems.
DaWei's Avatar, Join Date: Dec 2006
Team Leader
You do not have moveto, lineto, etc. You cannot use those. Where did you get this file? Please post the entirety of the code, as it now stands. That way, I can see the cout also.
Resh's Avatar, Join Date: May 2007
Go4Expert Member
This is the code as it stands now but the 6 errors still exist and refuse to be removed


Code:
#include<cmath>
#include<stdlib.h>
#include<windows.h>
#include<ctime>
#include<conio.h>
     

// The standard Borland 16 colors
#define MAXCOLORS       15;
enum colors { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY,
              LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE };

// Drawing Functions
void initgraph( int *graphdriver, int *graphmode, char *pathtodriver);
void lineto (int x,int y);

// Miscellaneous Functions
void moveto( int x,int y );
void setcolor( int color );

// The various graphics drivers
enum graphics_drivers { DETECT, CGA, MCGA, EGA, EGA64, EGAMONO, IBM8514, HERCMONO,
                        ATT400, VGA, PC3270 };

// Various modes for each graphics driver
enum graphics_modes { CGAC0, CGAC1, CGAC2, CGAC3, CGAHI, 
                      MCGAC0 = 0, MCGAC1, MCGAC2, MCGAC3, MCGAMED, MCGAHI,
                      EGALO = 0, EGAHI,
                      EGA64LO = 0, EGA64HI,
                      EGAMONOHI = 3,
                      HERCMONOHI = 0,
                      ATT400C0 = 0, ATT400C1, ATT400C2, ATT400C3, ATT400MED, ATT400HI,
                      VGALO = 0, VGAMED, VGAHI,
                      PC3270HI = 0,
                      IBM8514LO = 0, IBM8514HI };

// Constants for closegraph
#define CURRENT_WINDOW -1
#define ALL_WINDOWS -2
#define NO_CURRENT_WINDOW -3

// Window Creation / Graphics Manipulation
void closegraph( int wid=ALL_WINDOWS );

// Miscellaneous Functions
void moveto( int x,int y );
void setcolor( int color );

// User Interaction
int getch( );
int kbhit( );

double sin (double);
double cos (double);

const int X0=320;
const int Y0=240;
const double PI=3.14159;
const int NUME=30;
const int DENOM=100;
const int NUMBER=7;
const double RAD=3.0;
const double DELTHETA=0.1;
const int SEGS=60;
const int REDUX=3;
const int MIN=1;


class cluster
{
public:
	void display(int size,int x,int y);
};

class tendril
{
public:
	void display(int size,double theta,int x,int y);
};

void cluster::display(int size,int x,int y)
{
	if(kbhit())
		exit(0);
	for(int i=0;i<NUMBER;i++)
	{
		double theta=i*2*PI/NUMBER;
		moveto(x,y);
		tendril t;
		t.display(size,theta,x,y);
	}
}
void tendril::display(int size,double theta,int x,int y)
{
	for(int j=0;j<size;j++)
	{
		double chng=rand();
		 if ((chng < NUME) ?-1:1)
		 {
			double theta=theta+chng*DELTHETA;
			double x=x+RAD*sin(theta);
			double y=y+RAD*cos(theta);
		 }
		if(size<4)setcolor(RED);
			else if(size<13)setcolor(GREEN);
		else if(size<40)setcolor(LIGHTGREEN);
		else setcolor(YELLOW);
		lineto(x,y);
	}

	if(size>MIN)
	{
		cluster c;
		int newsize=size/REDUX;
		c.display(newsize,x,y);
	}
}
void main()
{
	int driver,mode;
	driver=VGA;
	mode=VGAHI;
	initgraph(&driver,&mode,"\\bc45\\bgi");
	rand();

	int x=X0,y=Y0;
	int size=SEGS;
	cluster c;
	c.display(size,x,y);
	getch();
	closegraph();
}
DaWei's Avatar, Join Date: Dec 2006
Team Leader
The only way you're going to get that to work is to get your hands on the libraries that shipped with Borland's C++ 4.5 or rewrite the screen controls with the Windows console API.