Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


C++ Programming Code Examples

Learn C++ Language

clearviewport() Function in C++ Programming Language

clearviewport() Function in C++
clearviewport() function clears the current viewport. setviewport will create a new viewport by accepting left, top, right and bottom coordinates. clearviewport() function will erase the drawing done on the view port only and not the whole screen. Cleardevice is the function used to clear the whole screen with the background color.
Syntax for clearviewport() Function in C++
#include <graphics.h> void clearviewport(void);
This function does not return any value. This function is used to set the view port for the graphics output. It sets the new display area for the graphics output.
/* setviewport() will create a new viewport by accepting left, top, right and bottom coordinates. The 5th argument for this function would be non zero, if you want to clip the drawing beyond this viewport. clearviewport() erases the viewport and moves the CP (current position) to home (0,0), relative to the viewport. */ /* erase the viewport and moves the current position to home (0,0) by clearviewport() function copde example. */ #include <graphics.h> #include <stdlib.h> #include <stdio.h> #include <conio.h> #define CLIP_ON 1 /* activates clipping in viewport */ int main(void) { /* request autodetection */ int gdriver = DETECT, gmode, errorcode, ht; /* 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 */ } setcolor(getmaxcolor()); ht = textheight("W"); /* message in default full-screen viewport */ outtextxy(0, 0, "* <-- (0, 0) in default viewport"); /* create a smaller viewport */ setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON); /* display some messages */ outtextxy(0, 0, "* <-- (0, 0) in smaller viewport"); outtextxy(0, 2*ht, "Press any key to clear viewport:"); getch(); /* wait for a key */ clearviewport(); /* clear the viewport */ /* output another message */ outtextxy(0, 0, "Press any key to quit:"); /* clean up */ getch(); closegraph(); return 0; }

"Linear extension" is another term for finding topological sort of a graph. A C++ program to print topological sorting of a DAG. Pointer to an array containing adjacency listsList. Graph








2 const variables row & col are used to define size. If we do not make both const then error found because without "const reserve word" they are behaving as variable. Before placing