Draw polygon

Hello,

I want to draw a polygon for my programme like this :
http://imageshack.us/photo/my-images/855/polygon.png

i followed some steps to draw polygon myself

1)search on internet about it but didnt understood

2)searched in c++ help it gave me "drawpoly" function to use but i didnt understood the working of that code or example.
i wrote the given example in c++.

the code is as follow:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>

#define closegraph();
#define drawpoly();
#define getmaxy();
#define getmaxx();
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy;
int poly[10];
initgraph(&gdriver, &gmode, "");
maxx = getmaxx();
maxy = getmaxy();
poly[0] = 20;
poly[1] = maxy/2;
poly[2] = maxx-20;
poly[3] = 20;
poly[4] = maxx-50;
poly[5] = maxy-20;
poly[6] = maxx/2;
poly[7] = maxy/2;
poly[8]=poly[0];
poly[9]=poly[1];
drawpoly( 7, poly);
getch();
closegraph();
return 0;
}

first it gave me error :
linker error : undefined symbol _closegraph in module file.cpp
it gave me for getmaxy, getmaxx(), drawpoly().

then i defined them and now its giving me error something like this :
maxx = getmaxx(); // expression syntax
maxy = getmaxy(); // expression syntax
drawpoly( 7, poly); // wrong number of arguments in call 'drawpoly'

so please help me in this working of programe.

and if u do write code please give info as comment in that code.

Thanking you.
smile :D
Last edited on
I don't even want to read that. Edit it and put in code tags.
Hello,

please dont get angry on me beacuse as you know i am beginer so i cant explain problems as an expert so please be helpful to me :D

and one more thing i want to ask also about the implementing of image in c++ by bimap (source : internet ) or something....

well i dont want that image working now 1st my polygon is important :D
and sry if i have written much and cooked your head :D :P

thank you
remove the defines in the following:
1
2
3
4
#define closegraph();
#define drawpoly();
#define getmaxy();
#define getmaxx(); 


and replace them with the return type.

PS: We are not getting angry at the fact that you are new, but in the first part of the forum it has a topic "Read First" or something like that, and so it is expected that you read it :)
To,
script coder


hello,

i didnt got you reply about replcaing those with return type. as per my knowledge i tried to replace it with void but still error.

1
2
3
4
void closegraph();
void drawpoly();
void getmaxy();
void getmaxx();


thank you.
Hello, guys please help me anyone
:@
What types of errors are you getting?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<graphics.h>
void closegraph();
void drawpoly();
void getmaxy();
void getmaxx();
int main(void)
{
int gdriver = DETECT, gmode, errorcode;
int maxx, maxy;
int poly[10];
initgraph(&gdriver, &gmode, "");
maxx = getmaxx();
maxy = getmaxy();
poly[0] = 20;
poly[1] = maxy/2;
poly[2] = maxx-20;
poly[3] = 20;
poly[4] = maxx-50;
poly[5] = maxy-20;
poly[6] = maxx/2;
poly[7] = maxy/2;
poly[8]=poly[0];
poly[9]=poly[1];
drawpoly( 7, poly);
getch();
closegraph();
return 0;
}


this is whole program and i made change over here :
1
2
3
4
void closegraph();
void drawpoly();
void getmaxy();
void getmaxx();


and this is giving error :
1) type mismatch in redeclaration of closegraph();
2) type mismatch in redeclaration of getmaxx();
3) type mismatch in redeclaration of getmaxy();

and can you give me some idea how do i use timer in c++ and also make it display on screen. i have searched over internet and c++ help but dont know how to implement it..

thank you.
Well, I'm gonna recommend you go refresh on the basics of C++. It looks as if you don't quite understand functions, and that is the source of your problems right now.
Topic archived. No new replies allowed.