Click here to Skip to main content
15,883,851 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hey guys i trying to build a function plotter and here it is my code so far....Iam geting an error in line 72 "glutInit(&argc;argc, argv);"


1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2065: 'amp' : undeclared identifier
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2143: syntax error : missing ')' before ';'
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2059: syntax error : ')'
line 72:glutInit(&argc, argv);

Any idea how to fix it? this is my code so far!!

C++
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>

/* Sample func itself */
float func(float x)
{
	return x*x;
}

/* Function plotting func */
void draw(float (* func)(float x), float x1, float x2, float y1, float y2, int N)
{
	float x, dx = 1.0/N;

	glPushMatrix(); /* GL_MODELVIEW is default */

	glScalef(1.0 / (x2 - x1), 1.0 / (y2 - y1), 1.0);
	glTranslatef(-x1, -y1, 0.0);
	glColor3f(1.0, 1.0, 1.0);

	glBegin(GL_LINE_STRIP);

	for(x = x1; x < x2; x += dx)
	{
		glVertex2f(x, func(x));
	}

	glEnd();

	glPopMatrix();
};

/* Redrawing func */
void redraw(void)
{
	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	
	draw(func, -3, 3, 0, 10, 10);

	glutSwapBuffers();
};

/* Idle proc. Redisplays, if called. */
void idle(void)
{
	glutPostRedisplay();
};

/* Key press processing */
void key(unsigned char c, int x, int y)
{
	if(c == 27) exit(0);
};

/* Window reashape */
void reshape(int w, int h)
{
	glViewport(0, 0, w, h);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(0, 1, 0, 1, -1, 1);
	glMatrixMode(GL_MODELVIEW);
};

/* Main function */
int main(int argc, char **argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
	glutCreateWindow("Graph plotter");

	/* Register GLUT callbacks. */
	glutDisplayFunc(redraw);
	glutKeyboardFunc(key);
	glutReshapeFunc(reshape);
	glutIdleFunc(idle);

	/* Init the GL state */
	glLineWidth(1.0);
  
	/* Main loop */
	glutMainLoop();
	return 0;
}
Posted
Updated 4-May-12 6:20am
v2

I don't see a call to glutInit_ATEXIT_HACK() anywhere and I have no intention of counting up to 72 to find out what is on that line. Are you certain this is the actual code you passed in to your compiler?
 
Share this answer
 
Comments
Erison Veshi 4-May-12 12:19pm    
yep ur were right i just copied an error from a different program. here it is the original error

1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2065: 'amp' : undeclared identifier
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2143: syntax error : missing ')' before ';'
1>c:\users\alb\documents\projects\laba8\eeee\eeee\ee.cpp(72): error C2059: syntax error : ')'
line 72:glutInit(&argc, argv);
Richard MacCutchan 4-May-12 12:32pm    
Well unless you give us a clue as to the exact line where the error occurs we cannot help. Once again I cannot find any reference to the symbol amp in the above source listing.
Ok just solved it! i have added "amp" by mistake to the code (just a typo)that`s why it gave the error. Thanks Richard for pointing it out.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900