Tag: strings
All the articles with the tag "strings".
-
How to Get a Substring in C++ with substr()
Extract a substring in C++ using the substr() method. Learn the position and length arguments, how to grab the rest of a string, and how to avoid out_of_range.
-
Convert a String to Uppercase or Lowercase in C++
Convert a C++ string to uppercase or lowercase with std::transform, toupper, and tolower. Full examples, a simple loop version, and the pitfalls to avoid.
-
C++ char to int Conversion: The Right Way (and the Common Trap)
Convert a char to an int in C++ correctly: the ch - '0' trick for digit characters, static_cast for ASCII codes, and stoi for strings, with clear examples.
-
How to Compare Strings in C++: ==, compare(), and strcmp Explained
Learn how to compare strings in C++ with ==, compare(), and strcmp. Understand case-insensitive comparison and common pitfalls, with working code examples.