PDA

View Full Version : array size const - not working


klaus1n3
25/04/2016, 08:52 PM
Code:

new const constLen = sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4;
new filePath[constLen]; // ERROR


Compiler:

error 008: must be a constant expression; assumed zero



Where is the problem?


Btw:

new const constLen = sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4;
printf("%i", constLen);
-> NO ERROR

introzen
25/04/2016, 09:15 PM
new filePath[sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4];

klaus1n3
25/04/2016, 09:46 PM
new filePath[sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4];

It actually works! Thanks. But I don't know why.

CodeStyle175
25/04/2016, 10:32 PM
wth is this stupid thing...
why you add 4 ? max name length is 24

introzen
26/04/2016, 07:23 AM
wth is this stupid thing...
why you add 4 ? max name length is 24

4 is most likely the size of a file extension. If you didn't notice, the variable itself is called filePath.