draw a circle

hello guys :)
simply the problem is that i wanna to draw a simple circle put when i use the function (initgraph "which i don't know it's use :D ") it just gives me this warning ( warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]) and when i run all i get is crashing :/ and this is the code :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 #include<graphics.h>

#include<conio.h>

void main()

{

int gd=DETECT,gm;

initgraph(&gd, &gm, "c:/tc/bgi ");

circle(330,180,100);

getch();

closegraph();

restorecrtmode();

}
Try

initgraph(&gd, &gm, "c:\\tc\\bgi "); // You need to use double slashes
Last edited on
TarikNeaj i tryed it and still the problem :(
Try using a c style string from where you input "c:/tc/bgi."

Something like this:

char path[] = "c:/tc/bgi";
germanchocolate@ when i run the program is crashing as i said :(
Use Double Slashes. single slashes are called escape sequences.

char path[] = "c://tc//bgi";

http://stackoverflow.com/questions/11466139/open-file-with-fopen-given-absolute-path
http://www.cplusplus.com/forum/general/126897/

Edit: Use int main not void main.
Last edited on
Tarik believe me it has nothing about the slashes :)
Future Epic wrote:
Tarik believe me it has nothing about the slashes :)


Is the variable "gm" supposed to not be initialized?

Edit: Just researched and found a lot of examples about this Turbo C++ library and all have not initalized it, so nevermind.
Last edited on
choclate@ i've already intialized it here int gd=DETECT,gm;
Try

1
2
3
const char* path = "c://tc//bgi";

initgraph(&gd, &gm, path);
Last edited on
Future Epic wrote:
choclate@ i've already intialized it here int gd=DETECT,gm;


You declared gm, but you didn't initialize it.

Either way, I'm not familiar with this Turbo C++ library, so the best I could do is link you to this earlier thread about someone using the library. Maybe it will help you with something you may have missed: http://www.cplusplus.com/forum/beginner/58846/
dear chocolate :)
i don't use Turbo but i don't know how to draw a circle and determine it's coord. but the noticed way that i found while searching .. if you know a way to draw a circle and simple i'd be so glade to tell me :)
Which library are you using then?
i have never ever tried to draw a circle this is the first time and i need a help (i'm using codeblocks)
Future Epic wrote:
i have never ever tried to draw a circle this is the first time and i need a help (i'm using codeblocks)


The reason that you're having errors is because there is no default graphics library that you can include(that I'm aware of), so you're calling non-existent functions.
no no i have downloaded the graphics.h library and it works .. if u know a way draw a circle tell me
You can use the library SFML. You can draw a circle there in 2 lines of code.

1
2
sf::CircleShape shape(50);
shape.setFillColor(sf::Color(100, 250, 50));


http://www.sfml-dev.org/tutorials/2.0/graphics-shape.php
Last edited on
Topic archived. No new replies allowed.