How to get no of letters in a string | Sololearn: Learn to code for FREE!
+ 2

How to get no of letters in a string

i want the answer but size of function doesn't do it

5th Apr 2017, 3:33 AM
harshith v
harshith v - avatar
7 Answers
+ 16
string str = "Hello World'; cout << str.length(); or you can do it the Hatsy Rei way with <cstring>, cout << strlen(str.c_str());
5th Apr 2017, 3:37 AM
Hatsy Rei
Hatsy Rei - avatar
+ 11
Let's just say that strings are actually character arrays. Try to play around with them :> If you still can't find out how, signal us on here.
5th Apr 2017, 7:31 AM
Hatsy Rei
Hatsy Rei - avatar
+ 6
Pro Tip : You can treat strings like an array too.
5th Apr 2017, 5:52 AM
Wen Qin
Wen Qin - avatar
+ 1
what is the method @hatsy rei thanks
5th Apr 2017, 3:50 AM
harshith v
harshith v - avatar
+ 1
i got it now.thanks for all
5th Apr 2017, 10:47 AM
harshith v
harshith v - avatar
0
also how to get the nth char of a string
5th Apr 2017, 4:22 AM
harshith v
harshith v - avatar
0
@wen quin how?
5th Apr 2017, 6:25 AM
harshith v
harshith v - avatar