Making your computer beep at you and your program crash!

Posts 1–2 of 2 · Page 1 of 1
Making your computer beep at you and your program crash!
Haven't done any real C++ in a long time (few months), hitting the book again and re-reading the chapter I left off. Anyways, it's overloading operators and I just wanted to do something interesting.

Doing this will make your computer beep at you and cause your program to crash!

Code:
string& operator*(string x) {
	x = "Test";
	return x;
}

int main()
{
	string y;
	cout << *y << endl;
}
Nothing important, not really amazing, just thought it was funny and I'd share it.


What looks like some background work the compiler is doing? This gets printed if you run that lol
You're dereferencing the memory which fucks up the stack.
What you're seeing is either the exports/imports of kernel32.dll
You end up printing binary data to the screen and one of those is what triggers a beep.

That's all there is to it.
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us