Printf long long int in C with GCC?

If you are on windows and using mingw, gcc uses the win32 runtime, where printf needs %I64d for a 64 bit integer. (and %I64u for an unsinged 64 bit integer) For most other platforms you’d use %lld for printing a long long. (and %llu if it’s unsigned). This is standarized in C99. gcc doesn’t come … Read more

Is int main() { } (without “void”) valid and portable in ISO C?

No. According to the normative wording of the standard, a definition using empty parentheses without the void keyword is not one of the forms that must be accepted, and strictly speaking the behavior of such a program is undefined. Reference: N1570 section 5.1.2.2.1. (The published 2011 ISO C standard, which is not freely available, has … Read more

How to properly add hex escapes into a string-literal?

Use 3 octal digits: char problem[] = “abc\022e”; or split your string: char problem[] = “abc\x12” “e”; Why these work: Unlike hex escapes, standard defines 3 digits as maximum amount for octal escape. 6.4.4.4 Character constants … octal-escape-sequence: \ octal-digit \ octal-digit octal-digit \ octal-digit octal-digit octal-digit … hexadecimal-escape-sequence: \x hexadecimal-digit hexadecimal-escape-sequence hexadecimal-digit String literal … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)