A C++ Easter Egg?

I was fixing a couple of minor bugs in a program I've been working on, when I made the mistake of typing cout<<string('\n', 1); instead of cout<<string(1,'\n');

I didn't get any compile errors and the programs reaction gave me a bit of a laugh. Instead of the blank line I wanted to put in, I got :):):):):):):):):):) (10 of them). It just made me wonder as a relative C++ beginner what other "easter eggs" are there that people might feel like sharing.

edit: aww, shame this forum doesn't support emoticons.
Last edited on
closed account (o1vk4iN6)
Not really a C++ easter egg, it's what windows prints for a character with a representation of 1. '\n' also happens to just be 10.
Last edited on
The second argment is the count of the first argument.

'\n' is on my and apparently your machine interpreted as character code 10. Due to implicit conversion to I assume std::size_t, you repeated the first char 10 times.
//cout<<string('\n', 1);
cout << '\n';
It's a Windows Console default codeset easter egg.
Topic archived. No new replies allowed.