Does the following fix the problem? Will it compile and run?
/* --- rect.h --- */ void setWidth( int w ); void setHeight( int h ); int getArea();
/* --- rect.c --- */ static int width = 0; static int height = 0; void setWidth( int w ) { width = w; } void setHeight( int h ) { height = h; } int getArea() { return height*width; }
/* --- mainRect.c --- */ #include <stdio.h> #include "rect.h" extern int height; extern int width; void main() { height = 4; width = 3; printf("Area: %d\n", getArea() ); }