System hang

I am using keep on string appending without limitation it crash the system

example i am using

std::string a="abc";
for( int i = 0 ; i < 50 ; i++)
{
a=a+a;
}
std::cout << a;

It will crash system
I need to give max limit to the string with out system hang.
Last edited on
It doesn't crash my system (32bit ppc/gcc 4.0), and it shouldn't crash yours either.

What do you mean by "crash"?
closed account (D80DSL3A)
It doesn't?
Wouldn't the resulting string be about 3*(2^50) = 10^15 = 100 1 million billion chars long?
Last edited on
It throws an exception (as you'd expect).

Why would you think it will crash?
Last edited on
Topic archived. No new replies allowed.