memesearch
Why Use C++ Instead of C?

Why Use C++ Instead of C?

Download Find similar pictures
Text on the meme
Why does everyone keep telling me to use c++? (self.programminghorror) submitted 2 hours ago by ZERIC020020 My task was to create a function in C that would take an integer, find the right-most 0, flip it to a 1, and flip all the 1's to the right of it to 0's. I don't understand why, but everyone tells me to just use c++ instead? Strange. uint32_t func(uint32_t c) { uint32_t i = 1; while (i != 0) { // Searches for the right-most 0 if ((c & i) == 0) { // Tests if the bit is a zero break; } i <<= 1; }; if (i != 0) { c |= i; // Flips the right-most 0 to a 1 } else { c = ~c; // If no zeros were found, then it was probably hidden in the carry bit, flip all 1's to the } i >>= 1; // Start at the 1 next to the right-most 0 while (i != 0) { // flip all 1's to the right of it to 0's c &= ~i; i >>= 1; }; return c; } Why are people so adamant that I use c++ instead of C?
What it means

Скриншот вопроса программиста о функции на C, которая манипулирует битами целого числа. Автор приводит чрезмерно сложную реализацию, а затем удивляется, почему все советуют ему использовать C++; шутка в том, что код выглядит как настоящий programming horror и сам объясняет рекомендацию.

Objects
Tags
Sources
Type
image
Size
800×502 · 60.7 KiB
Mood
саркастичный, абсурдный
Language
en
Added

Similar memes