The man page says snprintf is always supposed to be null terminiated... but the windows version doesn't live up the the specification. You're right about the -1 though, so it should be: _snprintf(buf, sizeof(buf), "%i", num);
buf[sizeof(buf)] = 0; whereas accoding to the specification you should just be able to do: _snprintf(buf, sizeof(buf), "%i", num); to see the error run this program: #include <stdio.h>
int main()
{
const char* !@#$%^&*o = "!@#$%^&*o";
char buf[5];
_snprintf(buf, sizeof(!@#$%^&*o), "%s",!@#$%^&*o);
//buf[ sizeof(!@#$%^&*o)] = 0;
printf("%i: '%s'\n",sizeof(!@#$%^&*o),buf);
return 0;
} ----------------------------------------------------------------------------------------------------------------------------- try this witchie (but sampacio is right about the more efficient way): int temp = t->Credit - Credsadded;
char cred1[10];
_snprintf(cred1, sizeof(cred1) - 1, "%i", temp);
for (int c = 0; cred1[c]; ++c)
cred1[c] -= '0';
int temp2 = t->Credit;
char cred2[10];
_snprintf(cred2, sizeof(cred2) - 1, "%i", temp2);
int len = (int)strlen(cred2);
for (int d = 0; cred2[d]; ++d)
cred2[d] -= '0';
for (int i=0; i<len; i++)
{
int t = i+20;
sendPrivate(p, ".*objoff "+(String)t+(String)cred1[i]);
sendPrivate(p, ".*objon " +(String)t+(String)cred2[i]);
}