Coin Change Dynamic Programming Problem and lot of Graph problems needed long depth recursion. That's why needed more than default stack size in c++. but i can't it. It is Possible to increase stack size in C++? I use c++ editor is Code Blocks 10.05.
Some programmer use in their code template is:
#pragma comment(linker, "/STACK: 2000000")
What is meaning of this part? Anyone can explain it?
As far as I know this feature works only in MS Visual C++. "/STACK:n" means that stack size is limited by n bytes. If you compile with GNU C++ the only way to increase the maximum stack size is to use a special compilation flag. You can see it here.
for GCC try it http://linux.die.net/man/2/setrlimit
Thank you @GeLo and @aram_gyumri
this command does not work in MSV C++ 2012. It displays the following error : error LNK1276: invalid directive '2000000' found; does not start with '/'
Try to remove the space between "STACK:" and "2000000".
It worked! Thanks.
Why do you want to do it in the program?
If you're just running the code on your computer (and use g++), then you can use -Wl,--stack,SIZE to set the size you wish for your run. Or ulimit on Linux.
If it's for a contest, you shouldn't do it. The stack size is the same for everyone (and it's usually mentioned in the rules). What you're doing is practically breaking into the testing system. You should just try to manage with the size that's set by default.