array size const - not working - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: array size const - not working (
/showthread.php?tid=605856)
array size const - not working -
klaus1n3 - 25.04.2016
Code:
PHP код:
new const constLen = sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4;
new filePath[constLen]; // ERROR
Compiler:
PHP код:
error 008: must be a constant expression; assumed zero
Where is the problem?
Btw:
PHP код:
new const constLen = sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4;
printf("%i", constLen);
-> NO ERROR
Re: array size const - not working -
introzen - 25.04.2016
PHP код:
new filePath[sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4];
Re: array size const - not working -
klaus1n3 - 25.04.2016
Quote:
new filePath[sizeof(FILE_PATH_PLAYERDATA) + MAX_PLAYER_NAME + 4];
|
It actually works! Thanks. But I don't know why.
Re: array size const - not working -
CodeStyle175 - 25.04.2016
wth is this stupid thing...
why you add 4 ? max name length is 24
Re: array size const - not working -
introzen - 26.04.2016
Quote:
Originally Posted by CodeStyle175
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.