14 Replies - 6654 Views - Last Post: 30 January 2011 - 05:35 AM Rate Topic: -----

#1 Guest_The Intel*


Reputation:

turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:23 AM

I am using Turbo C++ and compiled the sample circle graphics program present in the help. On compilation, it gives zero errors. Then, I run it. A black screen appears for a split second and the whole program closes. This is the problem with any graphics program I do.

Help me rectify the problem ASAP as I need it for doing the project.
Is This A Good Question/Topic? 0

Replies To: turbo c++ graphics closes on execution

#2 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1833
  • View blog
  • Posts: 4,927
  • Joined: 27-December 05

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:30 AM

Look at the C++ FAQs. They are there for a reason.
Was This Post Helpful? 1
  • +
  • -

#3 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:30 AM

Capslock off on headings please. :)

Can you tell us which API you are using, as well as post the code? :)
Was This Post Helpful? 0
  • +
  • -

#4 Guest_The Intel*


Reputation:

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:33 AM

Turbo C++ - The borland version.

This post has been edited by JackOfAllTrades: 29 January 2011 - 12:39 PM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0

#5 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2876
  • View blog
  • Posts: 11,051
  • Joined: 15-July 08

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:35 AM

Turbo C++ is several decades old at this point and will not run on modern systems. Please view this post:
http://www.dreaminco...60&#entry893260
Was This Post Helpful? 1
  • +
  • -

#6 Guest_The Intel*


Reputation:

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:37 AM

View PostThe Intel, on 29 January 2011 - 10:33 AM, said:

View PostButchDean, on 29 January 2011 - 10:30 AM, said:

Capslock off on headings please. :)

Can you tell us which API you are using, as well as post the code? :)


Turbo C++ - The borland version.


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

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;
   int radius = 100;

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

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

   /* draw the circle */
   circle(midx, midy, radius);

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



This post has been edited by ButchDean: 29 January 2011 - 10:40 AM

Was This Post Helpful? 0

#7 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:37 AM

View PostThe Intel, on 29 January 2011 - 05:33 PM, said:

View PostButchDean, on 29 January 2011 - 10:30 AM, said:

Capslock off on headings please. :)

Can you tell us which API you are using, as well as post the code? :)


Turbo C++ - The borland version.

And here's your answer. :)

Doesn't help at all, right? That's why we need some source.
Was This Post Helpful? 0
  • +
  • -

#8 Guest_Guest*


Reputation:

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:42 AM

I have pasted the code. That code along with anything with graphics does not work at all. I run it. The whole program closes

This post has been edited by JackOfAllTrades: 29 January 2011 - 12:39 PM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0

#9 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:43 AM

View PostThe Intel, on 29 January 2011 - 05:37 PM, said:

View PostThe Intel, on 29 January 2011 - 10:33 AM, said:

View PostButchDean, on 29 January 2011 - 10:30 AM, said:

Capslock off on headings please. :)

Can you tell us which API you are using, as well as post the code? :)


Turbo C++ - The borland version.


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

int main(void)
{
   /* request auto detection */
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy;
   int radius = 100;

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

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

   /* draw the circle */
   circle(midx, midy, radius);

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



Turbo C++ is so old that I don't have it installed either. Have you debugged to see what is happening exactly? For instance do you know if

if (errorcode != grOk)



Is true causing the program to terminate?
Was This Post Helpful? 0
  • +
  • -

#10 Guest_The Intel*


Reputation:

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:46 AM

I just compiled it line by line by pressing the F7 key. It goes on well till line 14 ( the initgraph line) after which it closes.

This post has been edited by JackOfAllTrades: 29 January 2011 - 12:38 PM
Reason for edit:: Removed unnecessary quote

Was This Post Helpful? 0

#11 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 291
  • View blog
  • Posts: 1,900
  • Joined: 25-October 06

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:51 AM

if I run this it draws a circle.
try running the .exe file from the Windows Command Prompt - it is probably not finding the .BGI files which drives the grapics
Was This Post Helpful? 0
  • +
  • -

#12 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 10:54 AM

View PostThe Intel, on 29 January 2011 - 05:46 PM, said:

I just compiled it line by line by pressing the F7 key. It goes on well till line 14 ( the initgraph line) after which it closes.

Then you are failing to initialize your graphics, hence the fact that they fail to show. When you debug that is the value of gdriver and gmode? Also does initgraph return any error codes?
Was This Post Helpful? 0
  • +
  • -

#13 Guest_The Intel*


Reputation:

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 11:01 AM

View PostButchDean, on 29 January 2011 - 10:54 AM, said:

View PostThe Intel, on 29 January 2011 - 05:46 PM, said:

I just compiled it line by line by pressing the F7 key. It goes on well till line 14 ( the initgraph line) after which it closes.

Then you are failing to initialize your graphics, hence the fact that they fail to show. When you debug that is the value of gdriver and gmode? Also does initgraph return any error codes?


Didn't quite get your first question.
On compilation, there are no errors whatsoever. On pressing alt + f7 that is, it checks for errors and finds absolutely none.
Was This Post Helpful? 0

#14 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: turbo c++ graphics closes on execution

Posted 29 January 2011 - 11:03 AM

View PostThe Intel, on 29 January 2011 - 06:01 PM, said:

View PostButchDean, on 29 January 2011 - 10:54 AM, said:

View PostThe Intel, on 29 January 2011 - 05:46 PM, said:

I just compiled it line by line by pressing the F7 key. It goes on well till line 14 ( the initgraph line) after which it closes.

Then you are failing to initialize your graphics, hence the fact that they fail to show. When you debug that is the value of gdriver and gmode? Also does initgraph return any error codes?


Didn't quite get your first question.
On compilation, there are no errors whatsoever. On pressing alt + f7 that is, it checks for errors and finds absolutely none.

horace got it working. Have you tried their suggestion?
Was This Post Helpful? 0
  • +
  • -

#15 Guest_The Intel*


Reputation:

Re: turbo c++ graphics closes on execution

Posted 30 January 2011 - 05:35 AM

View PostButchDean, on 29 January 2011 - 11:03 AM, said:

View PostThe Intel, on 29 January 2011 - 06:01 PM, said:

View PostButchDean, on 29 January 2011 - 10:54 AM, said:

View PostThe Intel, on 29 January 2011 - 05:46 PM, said:

I just compiled it line by line by pressing the F7 key. It goes on well till line 14 ( the initgraph line) after which it closes.

Then you are failing to initialize your graphics, hence the fact that they fail to show. When you debug that is the value of gdriver and gmode? Also does initgraph return any error codes?


Didn't quite get your first question.
On compilation, there are no errors whatsoever. On pressing alt + f7 that is, it checks for errors and finds absolutely none.

horace got it working. Have you tried their suggestion?


For me, the screen becomes pitch dark if I try running it from the exe file.
Was This Post Helpful? 0

Page 1 of 1