C sizeof a passed array [duplicate]

There is no magic solution. C is not a reflective language. Objects don’t automatically know what they are. But you have many choices: Obviously, add a parameter Wrap the call in a macro and automatically add a parameter Use a more complex object. Define a structure which contains the dynamic array and also the size … Read more

What is guaranteed about the size of a function pointer?

From C99 spec, section 6.2.5, paragraph 27: A pointer to void shall have the same representation and alignment requirements as a pointer to a character type. Similarly, pointers to qualified or unqualified versions of compatible types shall have the same representation and alignment requirements. All pointers to structure types shall have the same representation and … Read more

sizeof() operator in if-statement

sizeof is not a function, it’s an operator. The parentheses are not part of the operator’s name. It’s failing because the value generated has the unsigned type size_t, which causes “the usual arithmetic conversions” in which -1 is converted to unsigned, in which case it’s a very large number. Basically you’re comparing 4 > 0xffffffffu, … Read more

Why is int typically 32 bit on 64 bit compilers?

Bad choices on the part of the implementors? Seriously, according to the standard, “Plain ints have the natural size suggested by the architecture of the execution environment”, which does mean a 64 bit int on a 64 bit machine. One could easily argue that anything else is non-conformant. But in practice, the issues are more … Read more

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