09.05.2015, 07:22
Having used C languages before, I already realize that there's a difference between - the two specifiers - i and d when it comes to output and input. I had never bothered to test it out in PAWN though, but by chance it popped in my head lately and this is when the weird results came up...
Test code:
Result:
Is it my test code? Am I doing it wrong? If so, then can you drop good code that would give out correct/expected results?
Test code:
pawn Code:
// output test...
printf("printf(output) '051' with d specifier: %d", 051);
printf("printf(output) '051' with i specifier: %i", 051);
// input test...
new integer;
// first
sscanf("051", "d", integer);
if(integer == 51) // still octal
print("sscanf(input) '051' with d specifier: 51");
else if(integer == 41) // 41 the decimal of 051
print("sscanf(input) '051' with d specifier: 41");
// second
sscanf("051", "i", integer);
if(integer == 51) // still octal
print("sscanf(input) '051' with i specifier: 51");
else if(integer == 41) // 41 the decimal of 051
print("sscanf(input) '051' with i specifier: 41");
Code:
printf(output) '051' with d specifier: 51 printf(output) '051' with i specifier: 51 sscanf(input) '051' with d specifier: 51 sscanf(input) '051' with i specifier: 51