Page 109 - Programming Microcontrollers in C
P. 109

94     Chapter 2  Advanced C Topics

                   typedef struct
                   {
                       int x;
                       int y;
                   }Point;


                   typedef struct
                   {
                       Point center;
                       int radius;
                   }Circle;


                   typedef struct
                   {
                       Point p1;
                       Point p2;
                   }Rect;

                   Circle make_circle( Point ct, int rad )
                   {
                       Circle temp;
                       temp.center=ct;
                       temp.radius = rad;
                       return temp;
                   }


                   /* some useful macros */
                   #define min(a,b) (((a)<(b)) ? (a) : (b))
                   #define abs(a) ((a)<0 ? -(a) : (a))


                   /* function prototypes */
                   void draw_rectangle(Rect);
                   void draw_circle(Circle);

                   int main ( void )
                   {
                       Circle cir;
                       Point center;
                       Rect window = { {80,80},{600,400} };
   104   105   106   107   108   109   110   111   112   113   114