how to make this not stop?
-
hey guys i have this
int main(void)
{
while (malloc(50));
return 0;
}but after a couple of seconds it just asks to press any key to continue. what i would like it to do is just run till it crashes the program?
-
hey guys i have this
int main(void)
{
while (malloc(50));
return 0;
}but after a couple of seconds it just asks to press any key to continue. what i would like it to do is just run till it crashes the program?
What environment?
-
What environment?
? what do you mean.
-
? what do you mean.
Wimdows, MacOSX, Linux, GCC, Visual Studio.....?
-
hey guys i have this
int main(void)
{
while (malloc(50));
return 0;
}but after a couple of seconds it just asks to press any key to continue. what i would like it to do is just run till it crashes the program?
malloc
returns NULL when it can't allocate the requested memory. So your program simply allocates 50 bytes in a loop until memory runs out then exits (as NULL is treated as false by the while loop). Why would you expect a spectacular crash?Steve
-
Wimdows, MacOSX, Linux, GCC, Visual Studio.....?
windows, using c-free 5. i just want it to keep running untill it crashes or slows my comp down heaps
-
hey guys i have this
int main(void)
{
while (malloc(50));
return 0;
}but after a couple of seconds it just asks to press any key to continue. what i would like it to do is just run till it crashes the program?
int main()
{
while(true)
malloc(50);
return 0;
}The loop is now infinite, but the memory will sooner or later be exhausted. At that point,
malloc
will not allocate anymore, but the loop will still cycle forever. It will be very hard to stop it, having no more resource to create another process to kill the cycling one ...2 bugs found. > recompile ... 65534 bugs found. :doh: