August 27th, 2003, 10:11 AM
Simple Error with C
Hi all, At Last I was able to finish my project about Drawing the circle, and when I press some key the circle expand, and when I press other key the circle diminishes , now some errors!.Im using gcc to compile? Error:
circulo.c:38:2: warning: no newline at end of file
/tmp/cceKFeHK.o(.text+0x64): In function `dist':
: undefined reference to `sqrt'
collect2: ld returned 1 exit status
int dist(int ax, int ay, int bx, int by)
int center_x=20, center_y=20;
for(i=0; i<50; i++)
for(j=0; j<200; j++)
else printf(" ");
Thanks A lot.
August 27th, 2003, 11:46 AM
Re: Simple Error with C
For the sqrt problem, you need to include the correct header, which is <math.h>.
For the newline/end of file warning, try adding another (blank) line after the last closing brace and that may do it (if my memory serves me correctly - a quirk with some versions).
August 27th, 2003, 12:03 PM
That's odd, I could have sworn you didn't include <math.h> but on second glance you did. My bad. You'll need to include <stdlib.h> for system() though.
August 27th, 2003, 12:19 PM
Gerardoj, did you remember to include the math library?
gcc circle.c -lm
(that library option reads "minus ell emm")