how to Include gcc <graphics.h>?
ans
This post is about how you can run graphics program in Ubuntu platform.
Steps:
Step:1
Make sure that you have basic compilers installed. For this run the command:
Make sure that you have basic compilers installed. For this run the command:
     sudo apt-get install build-essential     sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 guile-1.8-dev libsdl1.2debian libart-2.0-dev libaudiofile-dev libesd0-dev libdirectfb-dev libdirectfb-extra libfreetype6-dev libxext-dev x11proto-xext-dev libfreetype6 libaa1 libaa1-dev libslang2-dev libasound2 libasound2-devNow download libgraph.
Copy libgraph-1.0.2.tar.gz to your home folder. Right click on it and select "Extract Here".
Then run following commands one by one.
     cd libgraph-1.0.2     ./configure     sudo make     sudo make install     sudo cp /usr/local/lib/libgraph.* /usr/libNow Ubuntu is ready to run graphics program. To do that add #include<graphics.h> in your C program.
>>In Turbo C we use following lines
     int gd=DETECT,gm; 
     initgraph(&gd,&gm,"c:\\tc\\bgi");     int gd=DETECT,gm; 
     initgraph(&gd,&gm,NULL);Example
copy following code
///--------------------------------------------------------------------
#include<graphics.h>
int main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,NULL); //<-use NULL
setcolor(BLUE);
line(100,100,200,200);
delay(5000); //wait for output
closegraph();
return(0);
}
//------------------------------------------------------------------------
>save code any location
>open terminal (Ctrl+Alt+t)
>go to program saved DIR $cd mydir
type following commands:
Run it with following command:
     gcc sample.c -o sample -lgraph     ./sampleoputput:-

 
Pond have got onto your website although implementing observe simply simply some bit submits. Soothing strategy for forseeable future, I will be bookmarking currently obtain types perform will come apart. Vintage Logo
ReplyDelete