Hi all, im new to this programming language and i tried to use my Xcode to build and run this code but i got a error :(, and another error is
i need a help guys - #include <GLUT/glut.h>
-
#include <stdlib.h>
-
#include <math.h>
-
-
const GLdouble twoPi =6.283185;
-
-
class scrPt {
-
public:
-
GLint x, y;
-
};
-
-
GLsizei winWidth = 400, winHeight =300;
-
-
void init (void)
-
{
-
glClearColor (1.0,1.0,1.0,1.0);
-
-
glMatrixMode (GL_PROJECTION);
-
gluOrtho2D (0.0,200.0,0.0,150.0);
-
}
-
. >>>>> the error is here (error: expected unqualified-id before '.' token)
-
.
-
.// Midpoint routines for displaying a circle
-
-
void pieChart (void)
-
{
-
scrPt circCtr, piePt;
-
GLint radius = winWidth/4;
-
-
GLdouble sliceAngle, previosSliceAngle = 0.0;
-
-
GLint k, nSlices = 12;
-
GLfloat dataValues[12] = {10.0,7.0,13.0,5.0,13.0,14.0,3.0,16.0,5.0,3.0,17.0,8.0};
-
GLfloat dataSum =0.0;
-
-
circCtr.x = winWidth/2;
-
circCtr.y =winHeight / 2;
-
circleMidpoint (circCtr, radius);
-
-
for (k =0; k< nSlices; k++)
-
dataSum += dataValues[k];
-
-
for (k =0; k< nSlices; k++) {
-
sliceAngle =twoPi * dataValues[k]/ dataSum + previousSliceAngle;
-
piePt.x = circCtr.x + radius *cos (sliceAngle);
-
piePt.y = circCtr.y + radius *sin (sliceAngle);
-
glBegin (GL_LINES);
-
glVertex2i(circCtr.x, circCtr.y);
-
glVertex2i(piePt.x, piePt.y);
-
glEnd ();
-
previousSliceAngle = sliceAngle;
-
}
-
}
-
-
-
void displayFcn (void)
-
{
-
glClear (GL_COLOR_BUFFER_BIT);
-
glColor3f (0.0,0.0,1.0);
-
pieChart (); >>>>>>>>>>>>>>>>( error: 'pieChart' was not declared in this scope )
-
glFlush ();
-
}
-
void winReshapeFcn (GLint newWidth, GLint newHeight)
-
{
-
glMatrixMode (GL_PROJECTION);
-
glLoadIdentity ();
-
gluOrtho2D (0.0, GLdouble (newWidth), 0.0, GLdouble (newHeight));
-
-
glClear (GL_COLOR_BUFFER_BIT);
-
-
/* Reset diaply-window size parameters. */
-
winWidth = newWidth;
-
winHeight = newHeight;
-
-
}
-
-
int main (int argc, char** argv)
-
{
-
glutInit (&argc, argv);
-
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
-
glutInitWindowPosition (100,100);
-
glutInitWindowSize (winWidth,winHeight);
-
glutCreateWindow ("Pie Chart");
-
-
init();
-
glutDisplayFunc (displayFcn);
-
glutReshapeFunc (winReshapeFcn);
-
-
glutMainLoop ();
-
-
}
12 17805
. >>>>> the error is here (error: expected unqualified-id before '.' token)
.
.//
All these three dots (before '>>>', on the next line , and before '//'), are they in the code? Why are they there?
yes they are in the code ... its refer to the Midpoint routines for displaying a circle.
Those periods don't look like legal C syntax. What do you expect them to do?
Midpoint routines for displaying a circle
Banfa 9,065
Expert Mod 8TB
Have you tried just removing lines 21,22 and 23 and compiling the code?
Banfa : yes i tried but its end up with error and when i correct the error my output is a pie chart without a circle :)
@sam23
Your source code snippet consists of - Include some header files (lines 1-3)
- Define a global variable (line 5)
- Define class scrPt (line 7)
- Define two more global variables (line12)
- Function init (lines 14-20)
- Three periods and a comment (lines 21-23)
- Function pieChart (lines 25-53)
- Function displayFcn (lines 56-62)
- Function winReshapeFcn (lines 63-75)
- Function main (lines 77-end)
Why do you so adamantly believe that the compiler interprets three periods as the instructions for inserting midpoint routines for displaying a circle?
Much more likely is that these periods were meant to be interpreted as an ellipsis in whatever source you cut and pasted this code from. That is, they indicate that a block of code (not needed to make the point) was omitted.
@sam23
At line 38, pieChart calls function circleMidpoint -- passing it the center and radius. You don't have a circleMidpoint function. You will need to write it.
donbock : i really dont understand :(
My lecturer just gave this coding and ask us to try to run it..
I dont have idea how to write fucntion for this circle Midpoint !
I would consult with your lecturer or teaching assistant as to how to write the midpoint function to complete the code. Perhaps this is the conclusion you are supposed to reach.
when you get the code from anybody, better walik through the code, what code is going to do with your system ?. It will help for development/debug knowledge.
Post your reply Sign in to post your reply or Sign up for a free account.
Similar topics
4 posts
views
Thread by matt hegarty |
last post: by
|
17 posts
views
Thread by Ange T |
last post: by
|
3 posts
views
Thread by mavis |
last post: by
|
4 posts
views
Thread by Igor Koretsky |
last post: by
|
9 posts
views
Thread by subramanian |
last post: by
|
9 posts
views
Thread by Mark Olbert |
last post: by
|
reply
views
Thread by =?Utf-8?B?a3Jpc2huYQ==?= |
last post: by
| |
reply
views
Thread by Stef Mientki |
last post: by
|
reply
views
Thread by Terry Reedy |
last post: by
| | | | | | | | | | |