I am trying to get a bezier curve drawn in a program.

These are the functions i have written for calculating the points, however it doesnt quite work and my brain has started to hurt so i need a bit of help.

Can anyone spot where ive gone wrong??

More code can be posted if you need to see the bigger picture.Code:int fact(int i) { if (i<=1) return 1; else return i*fact(i-1); } int nCi(int degrees, int i) { return fact(degrees)/(fact(degrees-i)*fact(i)); } double bu(int i,double u) { return nCi(degrees,i)*pow(1-u,degrees-1)*pow(u,i); } void C(double u, double Pt[3]) { for (int k=0; k<3; k++) { Pt[k]=0.0; for (int i=0; i<degrees+1; i++) { Pt[k]+=bu(i,u)*controlpoint[i][k]; } } } void calc_bezier_pts() { double u; for (int i=0;i<number;i++) { u=(i)/(number-1); C(u, bezier_curve[i]); } } int draw_bez() { calc_bezier_pts; for (int i=0;i<number;i++) { draw_line(x_bez[i],y_bez[i],x_bez[i+1],y_bez[i+1],9); } return 1; }