Thread: Array Size
View Single Post
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 11-07-2020 , 08:28   Re: Array Size
Reply With Quote #3

Quote:
Originally Posted by Shadows Adi View Post
Yea, it's possible, because:
First you create an array which let say will hold 33 cells ( new szCommands[33] )

Then, you create a new array which will have the value sizeof(szCommands) which will be 33 cells lenght, so practically this is same as new szTemp[33], but less hardcoded, if it's value depends on szCommands lenght.
What if i don't declare the length? It'd look something like this.

PHP Code:
new const szCommands[][] = {
    
"/glowmenu",
    
"/gm",
    
"/glow",
    
"!glowmenu",
    
"!gm",
    
"!glow"
}; 
PHP Code:
new szTemp[sizeof(szCommands)];
    for(new 
isizeof(szCommands); i++) {
        
formatex(szTempcharsmax(szTemp), "say %s"szCommands[i]);
        
register_clcmd(szTemp[i], "checkSettings");
    } 
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be