how can i use graphics.h?

heres an test code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <graphics.h>
#include <string>

using namespace std;
int main()
{
   int gd = DETECT, gm;
   int x = 320, y = 240, radius;
    char a[]="c:\\tc\\bgi\\";
   initgraph(&gd, &gm, a);

   for ( radius = 25; radius <= 125 ; radius = radius + 20)
      circle(x, y, radius);

   getch();
   closegraph();
   return 0;
}


when i execute, i get a memory leak.. why?
is because i must use an array of char's?
Last edited on
http://www.equestionanswers.com/c/c-dos-graphics.php

How do you know you have a memory leak?

Why do you include string, shouldn't it be string.h?
"How do you know you have a memory leak?"
when i execute, instead show the circle, don't show anything and the windows 7 give me a window with a message that stops responding and then close my program.
what is wrong?
if i can execute the problem isn't on my linker options(i add the lbbgi.a and "-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32" linker options\commands

"process returned 255 (0xFF)"
It's not using any of that stuff. You're using a library developed in 1991 for use on MS-DOS. It uses CGA, EGA, and probably VGA too, but that's about it. It predates Window 3. It is not a route for programming Windows graphics.
maybe these one: http://winbgim.codecutter.org
is outdated.
thank you so much. i will test another one. thank you
now works fine... i have found these tutorial: https://erainnovator.com/how-to-include-graphics-h-in-codeblocks/
readers: please read it until the end. because if we can't get the results, we can add the other library.
thank you so much for all
Topic archived. No new replies allowed.