String-Functions
String-Functions
Functions
.guides/img/FindFirstOf
string string1 = "The brown dog jumps over the lazy fox.";
string string2 = "brown";
challenge
Note that the index specification comes before the string you want the
system to add. For example, my_string.insert(0, "abc") will add the
string abc to the 0th index which is also the beginning of the string. To add
to the end of the string, you can use my_string.length(). Note that you do
not need to subtract 1 from my_string.length() because the system will
add characters starting at the index after the last character of the string.
string my_string = "Today is Satur";
my_string.insert(my_string.length(), "day");
challenge
challenge
my_string.replace(1, 2, "3")
challenge
string a = "High";
string b = " Five";
challenge
important
IMPORTANT
NOTE that the append() function is exclusively for strings. Thus, you
cannot include other data types like ints when using append() unless
they are converted to strings first. Additionally, when using the +
operator to combine two strings together, make sure that at least one
of the strings is a string variable. Otherwise, the system will think you
are trying to manipulate a string literal, which is not allowed.
Uppercase & Lowercase
.guides/img/StringToUpper
challenge
challenge