Posts
All the articles I've posted.
-
How to Remove a Character from a String in C++
Remove characters from a C++ string with erase, the erase-remove idiom, and remove_if. Delete by index, by value, all spaces, or every character matching a rule.
-
How to Sort a Map by Value in C++
A std::map always sorts by key, never by value. Here is the standard way to sort map entries by value in C++ using a vector of pairs, plus ties and top-N.
-
How to Check if a String Is a Number in C++
Check whether a C++ string is a valid number using stoi with exceptions, stringstream, or from_chars. Handles negatives, decimals and trailing junk correctly.
-
C++ String Length: size() vs length() vs strlen()
Get the length of a string in C++. Why size() and length() are identical, when to use strlen for char arrays, and the signed-unsigned trap that breaks loops.