Colours in Graphics.h - GCC - Graphics & Multimedia Lab - C++ Program

Colours in Graphics.h
GCC - Graphics & Multimedia Lab - C++ Program

Source code:
#include<graphics.h>
using namespace std;

int main()
{
    int i,j=1,k=0,gd=DETECT, gm,ych,xch; char* buf;
    
    char colours[18][15]={"BLACK","BLUE","GREEN","CYAN","RED","MAGENTA","BROWN","LIGHTGRAY","DARKGRAY","LIGHTBLUE","LIGHTGREEN","LIGHTCYAN","LIGHTRED","LIGHTMAGENTA","YELLOW","WHITE"};  
    initgraph(&gd, &gm,NULL);
    outtextxy(150,15, "Colours in Graphics.h.");      
    ych=0;xch=0;
     for(i=0;i<8;i++)
      {
       setcolor(i);
    for(j=k;j<k+50;j++)
    {
        line(j+50,80,j+50,200);
    }
    k=j;
    outtextxy(xch+50,80+ych,colours[i]);
    ych+=15;
    xch+=50;
    }
    k=0;ych=0;xch=0;
    for(i=8;i<=15;i++)
      {
       setcolor(i);
 
          for(j=k;j<k+50;j++)
    {
        line(j+50,230,j+50,350);
    }
    k=j;outtextxy(xch+50,235+ych,colours[i]);
    ych+=15;
    xch+=50;
    
    }
    getch();
    closegraph();
    return 0;
}
  
  
Output:
nn@linuxmint ~ $ g++ g5.cpp -lgraph
gp5.cpp: In function ‘int main()’:
gp5.cpp:11: warning: deprecated conversion from string constant to ‘char*’
nn@linuxmint ~ $ ./a.out
a.out: ../../src/xcb_io.c:249: process_responses: Assertion `(((long) (dpy->last_request_read) - (long) (dpy->request)) <= 0)' failed.
Aborted
nn@linuxmint ~ $ 

1 comment:

Related Posts Plugin for WordPress, Blogger...