Drawing shapes any simpler way ?

I'm a beginner and I have a task to make a circle and a square frame around it.... I started off reading about drawing a circle but I found mostly advanced methods using graphics or so and I finaly managed to come to this cource below but I keep getting the msg "The variable 'c' is being used without being initialized."

So I cannot even see what's the output. Can someone tell me why I get this msg and if I am on the right track?

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <windows.h>
using namespace std;

struct circle{
	double radius;
	double center_X;
	double center_Y;
	int px[360];
	int py[360];
};

struct frame{
	double up_r_X;
	double up_r_Y;
	double d_l_X;
	double d_l_Y;
	
};

int main()
{ circle c;
  cout<<"Please provide coordinates:\n";
  cin>>c.radius;
  cin>>c.center_X;
  cin>>c.center_Y;
  const double PI=3.14;
  float angle=0;  
  int i;
    HDC hdc;
	HPEN hPenOld;
	HPEN hLinePen;
	COLORREF  xio = RGB(255,0,0);
	hLinePen = CreatePen(PS_SOLID, 2, xio);
    hPenOld = (HPEN)SelectObject(hdc, hLinePen);
	double degree;
	double deg_to_rads; 
	deg_to_rads=0.018;
	for(i=1;i<360;i++)
	{ degree=i*deg_to_rads;
      c.px[i]=c.center_X+(c.radius*sin(degree));
	  c.py[i]=c.center_Y+(c.radius*cos(degree));
	  MoveToEx(hdc,c.px[i],c.py[i],NULL);
	  LineTo(hdc,c.center_X,c.center_Y);
		}
	 
}



In addition using structiors for the circle I am trying to draw and the frame around is part of the task.
Last edited on
I tried to compile your code and the compiler said nothing about 'c'. Are you sure the error was not about hdc ?

Besides, it should just be a warning, not an error.
Topic archived. No new replies allowed.