+ 2

Hi all. Im trying to convert a string to uppercase but the code doesnt run. Here's what i did:

https://code.sololearn.com/ccEa3zAXjQ1W/?ref=app

26th Mar 2018, 10:21 AM
Whiless
Whiless - avatar
9 Respuestas
+ 3
https://code.sololearn.com/c2RdXaYviz9Z/?ref=app
26th Mar 2018, 10:42 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
this one is the solution.
26th Mar 2018, 10:43 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
change the call to toupper into a lambda: transform(s.begin(), s.end(), s.begin(), [](char c) { return toupper(c); });
26th Mar 2018, 10:45 AM
Alex West
Alex West - avatar
+ 1
Thanks it worked very well @Raj can I ask why .begin() is included twice
26th Mar 2018, 11:01 AM
Whiless
Whiless - avatar
+ 1
sorry but I am not so good at explanation .... I can only make codes can't explain it....
26th Mar 2018, 11:11 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
cool. thanks
26th Mar 2018, 11:31 AM
Whiless
Whiless - avatar
+ 1
sorry once again
26th Mar 2018, 11:33 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
the second begin() is used to identify the beginning of the destination container or vector. In STL, vector, list, deque these are called containers in general term. Here, the source container is used as the destination container as well; however, we could have used a different container to store the uppercase letters.
27th Mar 2018, 10:18 PM
Alex West
Alex West - avatar
0
thank you a lot
27th Mar 2018, 10:21 PM
Whiless
Whiless - avatar