12.08.2014, 17:19
Hello, I'm making function that will create string with lowest possible calculated index for the string (may save LITTLE amount of memory
). You can too format this string inside function, but I have problem getting error:
error 001: expected token: "-string end-"
Thanks!

error 001: expected token: "-string end-"
pawn Код:
DeclareOptimiziedString("string", "Hello %s!", "Jack"); //Example usage -> this string should have 14 cells which is lowest possible
//Macro
#define DeclareOptimiziedString(%0,%1,%2) \
new %0[IndexCount(%1, %2)] \
format(%0, sizeof(%0), %1, %2);
//Func that calculates index of string (with format)
IndexCount(const src[], const fmat[])
{
new
count,
i;
while(i++ < strlen(fmat))
{
if(fmat[i] == '"' || fmat[i] == ',' || fmat[i] == 32)
{
continue;
}
count++;
}
return strlen(src) + count;
}