Difference between "const text[]" and "text[]"?
#9

const(ant) is used when a certain parameter shoulden't be changed. Let's say a function uses a password, would you like that function to change the password while it's doing it's thing? No you woulden't, and to make sure you don't make a mistakes and accidentally change it you may use const.

pawn Код:
// You don't want this function to change the password
// That would be dramatic (just an example)
stock DoSomethingWithPassword(const password[]) {
    // Whatever this function does, it could never change the value of password[] since that value is now a constant
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)