← Back to archive

Stdle #146 · strings · 2026-10-30

What does this C++ snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

#include <iostream>
#include <string>
int main() {
std::string s = "x";
s.resize(4, '-');
std::cout << s << " " << s.size() << "\n";
}
Strings
4 attempts left

Answer & explanation