← Back to archive

Stdle #162 · strings · 2026-11-15

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 = "hello world";
size_t sp = s.find(' ');
std::cout << s.substr(0, sp) << "|" << s.substr(sp + 1) << "\n";
}
Strings
4 attempts left

Answer & explanation