+ 1

How do work with each letter in a string

like displaying the first letter of a string input from a user or displaying how many letters a string has?

17th Jan 2018, 3:52 AM
Fig
Fig - avatar
7 Answers
+ 5
what language?
17th Jan 2018, 3:57 AM
Nope
Nope - avatar
+ 5
Remember strings can also be accessed as an array of characters. ex. string str ="hello world"; cout<<str[0]; will output: h
17th Jan 2018, 4:55 AM
Michael Simnitt
Michael Simnitt - avatar
+ 5
std::string str = "SoloLearn"; std::cout << str.length() << std::endl; The example-code above shows how to output the total character-count of a string.
9th Feb 2018, 3:08 PM
Fox
Fox - avatar
+ 1
thank everyone for the replies
17th Jan 2018, 4:58 AM
Fig
Fig - avatar
0
c++ sorry i forgot to add that in the question
17th Jan 2018, 4:10 AM
Fig
Fig - avatar