Well, in modern C++ this code would look like this:
std::array<int, 4> table; bool exists_in_table(int v) { for (auto &elem : table) { if (elem == v) return true; } return false; }
std::array<int, 4> table; bool exists_in_table(int v) { return std::ranges::contains(table, v); }
Well, in modern C++ this code would look like this:
Or even simpler: There's no shortage of footguns in C++, but nonetheless, modern C++ is safer than C.