View Full Version : problem with array
mickey
15th May 2006, 15:38
Hi I need to do this but I haven't problem with array (don't compile):
GLfloat position[4];
GLfloat[] getPosition() {return &position[0]; }
How can I do this? Thanks
jacek
15th May 2006, 15:42
How can I do this? Thanks
There are two solutions:
GLfloat[4] getPosition() {return position; }
or more efficient and more dangerous:
GLfloat * getPosition() {return &position[0]; }
// or
// GLfloat * getPosition() {return position; }
mickey
15th May 2006, 15:52
Sorry, your firset solution (I didn't try the second because I don't need a pointer value) give me this error:
C:\Qt\3.2.0Educational\include\qsignalslotimp.h(66 ): fatal error C1903: unable to recover from previous error(s); stopping compilation
jacek
15th May 2006, 16:40
unable to recover from previous error(s); stopping compilation
What is the first error?
wysota
15th May 2006, 16:51
Sorry, your firset solution (I didn't try the second because I don't need a pointer value)...
int arr[4] = {0, 1, 2, 3};
int *arrPtr = arr;
printf("%d\n", arrPtr[2]);
Guess what it prints...
mickey
16th May 2006, 15:57
There isn't first error..There are many errors after like those:
error C2061: syntax error : identifier 'getPosition'
error C3400: 'string': unexpected token/character encountered in attribute block
error C2334: unexpected token(s) preceding '{'; skipping apparent function body
jacek
16th May 2006, 16:05
There isn't first error..
That's quite interesting ;)
You will have to use one of these:
GLfloat * getPosition() {return &position[0]; }
// or
GLfloat * getPosition() {return position; }
mickey
16th May 2006, 16:39
OK. those solution are write. I wondered how I must code the first solution with [].
Thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2023 vBulletin Solutions Inc. All rights reserved.