I am getting an error when trying to pass temp1 back from the bounding_box function to my main function saying 'incompatible types in return' but the format of task1 is the same as the format of bound which I am trying to pass it too. They are both of the format boundingbox which was created in the struct command at the start of the program.
I cannot for the life of me work out why this is happening, as I have passed circ through as a value which also uses my own datatype and I had no problems with this.
Thanks in advance
Code:#include <stdio.h> typedef struct{ int x,y; int r; }circle; typedef struct{ int x1,y1; int x2,y2; }boundingbox; circle makecircle(int x, int y, int r) { circle temp; temp.x = x; temp.y = y; temp.r = r; return temp; } int bounding_box(circle circ) { int xa,xb,ya,yb; xa = circ.x - circ.r; ya = circ.y - circ.r; xb = circ.x + circ.r; yb = circ.y + circ.r; boundingbox temp1; temp1.x1 = xa; temp1.y1 = ya; temp1.x2 = xb; temp1.y2 = yb; return temp1; } int main() { circle circ; boundingbox bound; circ = makecircle(1,2,3); bound = bounding_box(circ); return 0; }



LinkBack URL
About LinkBacks


