Strings and Formatting
LockedLesson 3 of 25 · Syntax · Easy
Finish these first:Variables and Primitive Types →Or pass the tests below to unlock it now.
The big idea
A string holds text in C++ — words, names, or messages. Include <string at the top of the file (we already added it for you), then use std::string with double quotes "...": Always use double quotes "..." for strings in C++, and end every line with a semicolon ;.
Think of it like this: Think of a `std::string` like a strip of letters stored in order — double quotes tell C++ where your text starts and ends.
Read the lesson
A string holds text in C++ — words, names, or messages.
Include <string> at the top of the file (we already added it for you), then use std::string with double quotes "...":
std::string city = "Tokyo";
std::string name = "Maya";
std::string note = "Welcome!";
Always use double quotes "..." for strings in C++, and end every line with a semicolon ;.
Quick check
Which line stores text inside a C++ string variable named city?
Your challenge
Inside main(), create a string variable named greeting holding "Hello" (type std::string greeting = "Hello";).
More learning tools(compare languages, visual guide, related lessons)
Compare with another language
Similar to python.strings (86% overlap). UTF-8 string manipulation: template literals in JS, std::string in C++, immutable strings in Go, &str/String in Rust.
Visual walkthrough
A diagram, a step-by-step animation, and short captions for Strings and Formatting.
Learn this first
Opens up next
This is the last lesson in this branch.