12.12.2012, 20:57
(
Последний раз редактировалось Azazelo; 12.12.2012 в 21:50.
)
Any function to set string[] to uppercase?
Is there any default funcion for this ?
Is there any default funcion for this ?
stock uppercase(string[])
{
for(new i=0; i<strlen(string); i++)
{
string[i] = toupper(string[i]);
}
return string;
}
stock uppercase(string[])
{
for(new i=0; i<sizeof string; i++)
{
string[i] = toupper(string[i]);
}
return string;
}
stock uppercase(string[])
{
for(new i=0; i<(sizeof(string)); i++)
{
string[i] = toupper(string[i]);
}
return string;
}
indeterminate array size in "sizeof" expression |
stock uppercase(string[])
{
for(new i=0; i<strlen(string); i++)
{
string[i] = toupper(string[i]);
}
return string;
}
I've not actually looked in to the assembly in PAWN because frankly I don't care - if there is any difference it will be basically zero anyway. I do ++i because it is much better practice in C++ (ironically not ++C), as is "!=" rather than "<", and I'm used to thus doing it that way.
|
Are you doing ++i just for user preference, or is it actually faster to do that instead of i++ ?
|
main()
{
new
a = 10,
b = 10;
printf("A with pre-increment: %d", ++a);
printf("A after pre-increment: %d", a);
printf("B with post-increment: %d", b++);
printf("B after post-increment: %d", b);
}
[18:19:14] A with pre-increment: 11 [18:19:14] A after pre-increment: 11 [18:19:14] B with post-increment: 10 [18:19:14] B after post-increment: 11