Converting strings in a String Array into lowercase
Sep 3, 2017 at 1:37am UTC
Is there a way to convert strings inside an array into lowercase?
So say I have an array like:
1 2 3 4
String mainArray[] = {"Dog" , "caT" , "ElepHANT" , "Hungry" , "LION" }
// So mainArray[0] = "Dog" mainArray[1] = "caT" etc.
// So i get:
mainArray[] = {"dog" , "cat" , "elephant" , "hungry" , "lion" }
Is there a function or method to iterate through the array and transform each string into lowercase?
Last edited on Sep 3, 2017 at 1:43am UTC
Sep 3, 2017 at 2:15am UTC
When you aren't using straight C++ it is a good idea to also indicate what variant or library you are using. If I were to guess, use the built-in
String.ToLower()
method.
1 2
for (auto & s : mainArray)
s = s->ToLower();
The documentation is your friend.
Hope this helps.
Topic archived. No new replies allowed.