Sem 4‎ > ‎CG LAB‎ > ‎

0 Starting Programs

posted Dec 18, 2011, 2:30 AM by Neil Mathew   [ updated Jan 1, 2012, 11:25 PM ]
[[ The Shortcuts ]]


( DevCpp )

F2:                   Save
Alt F2:             Close O/P Window
Ctrl F9:            Compile
Ctrl F10:           Run


( Turbo C using DOSBOX )
F2:                   Save F3:                   Open F10:                 Last Menu Item Selected Alt+Enter:        Exit/Open Full Screen Mode
Alt + PrtScr:      Specific Window screenshot

[[ Anyway...  ]]
First things first, you gotta get familiar with the syntax:


Dev C++ Syntax:

 
#include <graphics.h>


int main()
{    

initwindow(1200,800);     


setcolor(3);      circle(getmaxx()*0.5,getmaxy()*0.5,200);  
 

while(!kbhit());    

closegraph();        
   
return 1;
}

 
#include <graphics.h>
#include <conio.h>

int main()
{    

int gdriver = DETECT, gmode;     initgraph(&gdriver, &gmode, "C:/TC/BGI/");
  
setcolor(3);      circle(getmaxx()*0.5,getmaxy()*0.5,200);
   
getch();

closegraph();        
  
return 1;
}




Turbo C Syntax:
.
 
 #include<graphics.h>
 #include<stdlib.h>
 #include<stdio.h>
 #include<conio.h>

 int main(void)
 {

         int gdriver = DETECT, gmode;     
         initgraph(&gdriver, &gmode, "C:/TC/BGI/");

 int i,j;  
//OBSERVATION:
//all declarations after gdriver declaration only, not above it.
        
         setcolor(3);  
         circle(getmaxx()*0.5, getmaxy()*0.5, 200);  
         
        getch();

        closegraph();

        return 0;
}


NOTICE: 

The line while(!kbhit()); does what getch(); does.


 
Left hand side, 

Using initwindow(x,y)

In DevC, only on window opens up.

I can specify the size of output window.




Right hand side, 

Using initgraph
addr_gdriver, addr_gmode, location_bgi_library)

In DevC, two windows opens up, 
one with the graphics, and 
another for text (cout).

The size is fixed at 641x481. 




FINAL OUTPUT: