Indexing an `unsigned long` variable and printing the result

As a preface, this program will not necessarily run exactly like how it does in the question as it exhibits implementation-defined behavior. In addition to this, tweaking the program slightly can cause undefined behavior as well. More information on this at the end. The first line of the main function defines an unsigned long foo … Read more

Why is assigning a value to a bit field not giving the same value back?

Bit-fields are incredibly poorly defined by the standard. Given this code struct mystruct {int enabled:1;};, then we don’t know: How much space this occupies – if there are padding bits/bytes and where they are located in memory. Where the bit is located in memory. Not defined and also depends on endianess. Whether an int:n bitfield … Read more

Is sizeof(bool) defined in the C++ language standard?

sizeof(bool) is implementation defined, and the standard puts notable emphasis on this fact. ยง5.3.3/1, abridged: sizeof(char), sizeof(signed char) and sizeof(unsigned char) are 1; the result of sizeof applied to any other fundamental type is implementation-defined. [Note: in particular, sizeof(bool) and sizeof(wchar_t) are implementation-defined.69)] Footnote 69): sizeof(bool) is not required to be 1.

Why should I not #include ?

Including <bits/stdc++.h> appears to be an increasingly common thing to see on Stack Overflow, perhaps something newly added to a national curriculum in the current academic year. I imagine the advantages are vaguely given thus: You only need write one #include line. You do not need to look up which standard header everything is in. … Read more

Undefined, unspecified and implementation-defined behavior

Undefined behavior is one of those aspects of the C and C++ language that can be surprising to programmers coming from other languages (other languages try to hide it better). Basically, it is possible to write C++ programs that do not behave in a predictable way, even though many C++ compilers will not report any … Read more

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