How do I change the size of the stack in c++? I would like to use larger arrays, and the stack overflows when I make them as large as I would like.
Thanks,
MadCow
How do I change the size of the stack in c++? I would like to use larger arrays, and the stack overflows when I make them as large as I would like.
Thanks,
MadCow
Use std::vector?
Just Google It. √
(\ /)
( . .)
c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.
Thanks, that does the trick. Will I notice any difference performance wise?
You shouldn't, vectors shouldn't be much slower then an array, if not the same.
If any part of my post is incorrect, please correct me.
This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.
> How do I change the size of the stack in c++?
It depends on your OS and compiler.
Besides, as Hunter2 suggested, take it as a hint that you should be looking for a better solution
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Thats interesting I though the stack was suposed to grow when all of it's space was used up?
Originally Posted by MadCow257http://www.artima.com/intv/goldilocks.htmlOriginally Posted by Bjarne Stroustrup
Just out of curiosity, why would you think that?Thats interesting I though the stack was suposed to grow when all of it's space was used up?
> Thats interesting I though the stack was suposed to grow when all of it's space was used up?
That depends....
Just a little under 2MB here.Code:$ ulimit -a core file size (blocks, -c) unlimited data seg size (kbytes, -d) unlimited file size (blocks, -f) unlimited open files (-n) 256 pipe size (512 bytes, -p) 8 stack size (kbytes, -s) 2043 cpu time (seconds, -t) unlimited max user processes (-u) 63 virtual memory (kbytes, -v) 2097152
Of course I could set "unlimited", but it would still be limited by the very real limits of physical memory / swap space / address space.
How you manipulate the same thing in say windows is another matter.
You can't just put char x[1000000] inside a recursive function and sit back hoping that it'll work.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.