Tags: #stackoverflow
https://stackoverflow.com/questions/40481286/why-does-the-size-of-this-stdstring-change-when-characters-are-changed
https://stackoverflow.com/questions/40481286/why-does-the-size-of-this-stdstring-change-when-characters-are-changed
Stackoverflow
Why does the size of this std::string change, when characters are changed?
I have an issue in which the size of the string is effected with the presence of a '\0' character. I searched all over in SO and could not get the answer still.
Here is the snippet.
int main()
{
...
Here is the snippet.
int main()
{
...
Tags: #stackoverflow #string
https://stackoverflow.com/questions/40592298/why-would-you-compare-a-with-0x41
https://stackoverflow.com/questions/40592298/why-would-you-compare-a-with-0x41
Stackoverflow
Why would you compare 'A' with 0x41?
I was looking at some C++ code and found the following construct:
if('A' == 0x41) {
// ...
} else if('A' == 0xc1) {
// ...
} else {
// ...
}
I get a Visual Studio warning saying:
Warning...
if('A' == 0x41) {
// ...
} else if('A' == 0xc1) {
// ...
} else {
// ...
}
I get a Visual Studio warning saying:
Warning...
Tags: #stackoverflow #binary #operator
https://stackoverflow.com/questions/40751662/is-a-b-255-255-the-same-as-a-b-255
https://stackoverflow.com/questions/40751662/is-a-b-255-255-the-same-as-a-b-255
Stack Overflow
Is ((a + (b & 255)) & 255) the same as ((a + b) & 255)?
I was browsing some C++ code, and found something like this:
(a + (b & 255)) & 255
The double AND annoyed me, so I thought of:
(a + b) & 255
(a and b are 32-bit unsigned integers)
I
(a + (b & 255)) & 255
The double AND annoyed me, so I thought of:
(a + b) & 255
(a and b are 32-bit unsigned integers)
I
Tags: #bool #ternary #stackoverflow
https://stackoverflow.com/questions/43139144/why-is-the-ternary-operator-used-to-define-1-and-0-in-a-macro
https://stackoverflow.com/questions/43139144/why-is-the-ternary-operator-used-to-define-1-and-0-in-a-macro
Stackoverflow
Why is the ternary operator used to define 1 and 0 in a macro?
I'm using an SDK for an embedded project. In this source code I found some code which at least I found peculiar. In many places in the SDK there is source code in this format:
#define ATCI_IS_LOWER(
#define ATCI_IS_LOWER(
Tags: #stackoverflow #if vs #ifelse
https://stackoverflow.com/questions/43202012/if-statement-vs-if-else-statement-which-is-faster
https://stackoverflow.com/questions/43202012/if-statement-vs-if-else-statement-which-is-faster
Stack Overflow
If statement vs if-else statement, which is faster?
I argued with a friend the other day about those two snippets. Which is faster and why ?
value = 5;
if (condition) {
value = 6;
}
and:
if (condition) {
value = 6;
} else {
value = 5;...
value = 5;
if (condition) {
value = 6;
}
and:
if (condition) {
value = 6;
} else {
value = 5;...