← C++ from Scratch Lesson 10 of 62 · 5 XP

Warm-up: word length warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

std::string holds text. Its length is known by the size() method:

std::string s = "hello";
std::cout << s.size() << '\n';   // 5

Strings need #include <string>.

Task. Read a word and print how many characters it has.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.