S
scooper
I have a graphics program writen in DOS Borland C++ and would like to
translate into Turbo C++.
What changes do I need to make to this program?
Thanks to all,
scooper.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* select a driver and mode that supports */
/* multiple drawing colors. */
int gdriver = EGA, gmode = EGAHI, errorcode;
int color, maxcolor, x, y;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
/* maximum color index supported */
maxcolor = getmaxcolor();
/* for centering text messages */
settextjustify(CENTER_TEXT, CENTER_TEXT);
x = getmaxx() / 2;
y = getmaxy() / 2;
/* loop through the available colors */
for (color=1; color<=maxcolor; color++)
{
/* clear the screen */
cleardevice();
/* select a new background color */
setcolor(color);
/* output a messsage */
sprintf(msg, "Color: %d", color);
outtextxy(x, y, msg);
getch();
}
/* clean up */
closegraph();
return 0;
}
translate into Turbo C++.
What changes do I need to make to this program?
Thanks to all,
scooper.
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
/* select a driver and mode that supports */
/* multiple drawing colors. */
int gdriver = EGA, gmode = EGAHI, errorcode;
int color, maxcolor, x, y;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
/* maximum color index supported */
maxcolor = getmaxcolor();
/* for centering text messages */
settextjustify(CENTER_TEXT, CENTER_TEXT);
x = getmaxx() / 2;
y = getmaxy() / 2;
/* loop through the available colors */
for (color=1; color<=maxcolor; color++)
{
/* clear the screen */
cleardevice();
/* select a new background color */
setcolor(color);
/* output a messsage */
sprintf(msg, "Color: %d", color);
outtextxy(x, y, msg);
getch();
}
/* clean up */
closegraph();
return 0;
}