``````int var = 0;
int* ptr = &var;
ptr[0] = 5;
std::cout << ptr[0];``````
``````    string sum_numbers(string a, string b) {
char ca, cb, ci, out, co = '0';
string result = "";
while (a.size() > 0 || b.size() > 0 || co != '0') {
ci = co; ca = '0'; cb = '0';
if (a.size() > 0) {ca = a.back(); a.pop_back();}
if (b.size() > 0) {cb = b.back(); b.pop_back();}
result = ((((ca != cb) ? '1' : '0') != ci) ? '1' : '0') + result;
co = ((((ca == '1' && cb == '1') ? '1' : '0') == '1' ||
((((ca != cb) ? '1' : '0') == '1' && ci == '1') ? '1' : '0') == '1') ? '1' : '0');
}
return result;
}``````

Scary stuff

``````#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iterator>

constexpr int N = 10;

int main() {
std::vector<int> even;
std::vector<int> odd;

even.resize(N);

// Fill up the 'even' vector with integers starting from from 1 through 'N'
std::iota(even.begin(), even.end(), 1);

// Segregate the odd and even integers from each other

for (auto it = even.begin(); it != even.end(); ++it)
if (*it % 2 != 0) {
// If the number is odd, put it in the 'odd' vector
odd.push_back(*it);
// Remove the number from the even vector
even.erase(it);
}

// Print the result

std::cout << "Even numbers: ";
std::copy(even.begin(), even.end(), std::ostream_iterator<int>(std::cout, " "));

std::cout << "\nOdd numbers: ";
std::copy(odd.begin(), odd.end(), std::ostream_iterator<int>(std::cout, " "));

std::cout << '\n';
}
``````

Seems fine to me... C++ couldn't possibly be THAT evil to introduce another nuanced and verbose complexity in there, right?

``````  if(!Hardware::initialize()) {
Serial.println("Hardware initialization failed!");
for(;;){}
}

if(!UI.begin()) {
Serial.println("SSD1306 allocation failed");
for(;;){}
}``````

For is best ever, why even bother with While, or even Return... Source of code: https://github.com/MausTec/nogasm-wifi/blob/master/ESP32_WiFi.ino

``````void winner(int score[4])
{

if (score[0] > score[1] > score[2] > score[3])
cout << "The winner is the Player 1 with " << score[0] << " points.";
else if (score[1] > score[0] > score[2] > score[3])
cout << "The winner is the Player 2 with " << score[1] << " points.";
else if (score[2] > score[0] > score[1] > score[3])
cout << "The winner is the Player 3 with " << score[2] << " points.";
else if (score[3] > score[2] > score[1] > score[0])
cout << "The winner is the Player 4 with " << score[3] << " points.";
}``````
``if ((&inactiveSlot)->GetFirstSlot() == RuntimeLib::INVALID_SLOT) {``

Dot dude...

``if(!strncmp(pcTagName,strlim,(int)strlen(strlim))) return "";``
``auto settingsFileSize = static_cast<int>(sizeof(_settings));``

This was in release branch for a month. Casting wasn't even necessary.

``````double zuida(std::vector<double> vec) {
std::vector<double> temp;
for(int i = 0; i < vec.size(); i++)
temp.push_back(vec[i]);
notend:
if(temp.size() > 0) {
if(temp.size() < 2) {
double tmp = *(&temp[0]);
return tmp;
}
else if(temp.size() >= 2) {
double mini = temp[0];
int ind = 0;
for(int i = 0; i < temp.size(); i++)
if(temp[i] < mini) {
mini = temp[i];
ind = i;
}
temp.erase(temp.begin() + ind);
goto notend;
}
}
}``````

The beauty is that every case is the best (also worst) case!

``````int main() {
int error_code = some_function();
if (error_code == 1) {
// In case of error, crash the program by eating up memory
while (true) new int;
}
}``````
``````void MagicUnit::getSomeVoltage(std::uint64_t w_data, double &val)
{
std::uint64_t r_data = 0;
val = r_data;
val /= 16; // shit right 4 bits
val *= 0.004;
val -= 8.192;
}
``````
``````  ierr = pxmlIn->GetData(pcTag, *pTData);
*pbDataValid = bool((ierr==0)&&(iLen>0));  // enabled if: not empty string and vaild (number?)
if (*pbDataValid)  iErr += ierr;``````
#53 C++ +10
``````int chromosome::getScore()
{
return this->getScore();
}``````
``````#define private public
#define protected public
#define class struct

#include "your_private_parts.hpp"
// ...

#undef class
#undef protected
#undef private

// ...``````

Fails miserably if `template <class>`, `template <template <class> class>` or their variations are found anywhere inside your header. :(

``````for (int i = 0;i < n / 2;i++)
{
while (num[a[p].id].n == 0 || num[num[a[p].id].nxt].n == 0)
{
p++;
}
printf("%d %d ", num[a[p].id].n, num[num[a[p].id].nxt].n);
num[a[p].id].n = 0;
num[num[a[p].id].nxt].n = 0;
num[num[a[p].id].lst].nxt = num[num[a[p].id].nxt].nxt;
num[num[num[a[p].id].nxt].nxt].lst = num[a[p].id].lst;
}``````