Search code examples
cbgi

fullscreen c program app not working in windows 7/8


Hy guys, I wrote a program to draw a line in C programming. As we know, windows7/8 doesn't support full screen directly, When I compiled from turboC++, it ran currectly, but when I build it and went to the turboC++ folder and executed from there, it gives me a message that this platform doesnt support full screen apps, now what should I do so that it runs in windows 7/8. The code I wrote is:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
{
   clrscr();
   /* request auto detection */
   int gdriver = (DETECT)/3, gmode, errorcode;
   int midx, midy;

   /* initialize graphics and local variables */
   initgraph(&gdriver, &gmode, "C:/TURBOC3/BGI/");

   /* 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 */
   }

   midx = getmaxx() / 2;
   midy = getmaxy() / 2;
   setcolor(getmaxcolor());

   line(midx, midy, midx/2,midy/2);

   /* clean up */
   getch();
   closegraph();
   return 0;
}

what may be the solution? I am just a beginner at C... Sorry if I am not able to make you clear... I have also attached the picture of error what I got,..The error I got...


Solution

  • use dosbox for this purpose follow the steps

    1.Install the software DOSBoxdownload

    2.Download and extract TC

    3.Make sure that the DOSBox and TC are in the same directory and the TC.exe application is in the Folder TC>>BIN>>TC.exe for this to work.

    4.Run DOSBox and Type the following commands at the command prompt mount d c:

    5.Now you should get a message which says: Drive D is mounted as a local directory c: Type d: to get into d:

    6.Next follow the commands below: cd tc

    cd bin

    and tc or tc.exe

    7.In Turbo C Editor, go to Options>Directories>Change Directories>Change the source of TC to the source directory [D]

    8.Go to Program Files>DosBox folder.>DOSBox 0.74 Options> and edit it using notepad(move to the end of file)

    9>.And paste the code as shown in below.

    mount d c:\

    d:

    cd tc

    cd bin

    tc.exe

    By the end of this step, Turbo C will load automatically as you click on DosBox icon.