+ 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?
7 Answers
+ 5
what language?
+ 5
Remember strings can also be accessed as an array of characters.
ex.
string str ="hello world";
cout<<str[0];
will output: h
+ 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.
+ 1
thank everyone for the replies
0
c++
sorry i forgot to add that in the question