Issue with sizeof(array) strings and enums
#1

I'm trying to get the size of a string contained in an array (NOT the length of text in the string).

This code:
Код:
#define SALT_LENGTH 65
#define PASSWORD_LENGTH 65

enum e_PlayerInfo {
	Player_Name[MAX_PLAYER_NAME],
	Player_Password[PASSWORD_LENGTH],
	Player_Salt[SALT_LENGTH]
};

new Player[MAX_PLAYERS][e_PlayerInfo];

OnGameModeInit() {
	printf("%i", sizeof(Player[0][Player_Name]));
}
...returns these compile errors:
Код:
 includes\../player/account.pwn(47) : error 001: expected token: "]", but found "-integer value-"
 includes\../player/account.pwn(47) : warning 215: expression has no effect
 includes\../player/account.pwn(47) : error 001: expected token: ";", but found "]"
 includes\../player/account.pwn(47) : error 029: invalid expression, assumed zero
 includes\../player/account.pwn(47) : fatal error 107: too many error messages on one line
I'm not an amazing coder, and I'm just beginning to learn, but this seems odd to me.
As far as I can tell, this should work just fine, but sizeof() refuses to work like this.
I swear I've used it before like this, and I would check, but that project was deleted.

Am I missing something silly, or have I done something horribly wrong?
Any help is appreciated, thanks!
Reply


Messages In This Thread
Issue with sizeof(array) strings and enums - by Aire - 06.12.2018, 14:37
Re: Issue with sizeof(array) strings and enums - by coool - 06.12.2018, 14:56
Re: Issue with sizeof(array) strings and enums - by Aire - 06.12.2018, 15:13
Re: Issue with sizeof(array) strings and enums - by Aire - 06.12.2018, 16:12
Re: Issue with sizeof(array) strings and enums - by Aire - 06.12.2018, 19:15

Forum Jump:


Users browsing this thread: 1 Guest(s)