C++ Programming Code Examples
Learn C++ Language
initgraph() Function in C++ Programming Language
initgraph() Function in C++
To create a program in Graphics Mode, the first step would be to include the header file graphics.h. This file is required for Graphics programming. After this, the graphics have to be initialized.
C Language supports 16 Bit's MS-DOS environment. Initializing the Graphics mode is to call various functions, one such is called initgraph.
initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver), and putting the system into graphics mode. To start the graphics system, first call the initgraph function. initgraph loads the graphics driver and puts the system into graphics mode. You can tell initgraph to use a particular graphics driver and mode, or to autodetect the attached video adapter at run time and pick the corresponding driver. If you tell initgraph to autodetect, it calls detectgraph to select a graphics driver and mode. initgraph also resets all graphics settings to their defaults (current position, palette, color, viewport, and so on) and resets graphresult to 0.
Syntax for initgraph() Function in C++
void initgraph (int *graphdriver, int *graphmode, char *pathtodriver);
graphdriver
This is an integer that indicates that the graphics driver has been used.
graphmode
It is also an integer value that detects the available graphics driver and initializes the graphics mode according to its highest resolution.
pathtodriver
This is the path of the directory that first searches the initgraph function graphics driver. If the graphics driver is not available then the system searches it in the current directory.
It is necessary to pass the correct value of the three parameters in the initgraph function or else an unpredictable output is obtained.
intgd = DETECT, gm;
initgraph (&gd, &gm, " ");
/* initgraph initializes the graphics system by loading a graphics driver from disk (or validating a registered driver), and putting the system into graphics mode.
To start the graphics system, first call the initgraph function. initgraph loads the graphics driver and puts the system into graphics mode. You can tell initgraph to use a particular graphics driver and mode, or to autodetect the attached video adapter at run time and pick the corresponding driver. */
int DGraphics::Init( int gmode )
{
int gdriver = VGA,
errorcode;
gdriver=installuserdriver("SVGA256",NULL);
initgraph(&gdriver, &gmode, "");
if ( (errorcode = graphresult()) != grOk )
{
cout << "Error: Graphics - %s\n" << grapherrormsg(errorcode);
return FALSE;
}
ActiveMode=gmode;
return TRUE;
}
This is a "C++ Program" to implement "Gauss Seidel" Method. In numerical Linear Algebra, the Gauss-Seidel method, also known as the Liebmann method or "method of successive"
All the "variables" must be declared before to use or initial statements of the block or main or function or global. Variables should specify with data type. And it binds a "data type" and
To transpose any matrix in C++ Programming language, you have to first ask to the user to enter the matrix and "replace row" by column and column by row to "transpose" that matrix