fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. void f(unsigned N)
  6. {
  7. const unsigned stack_array_size=10;
  8. char stack_array[stack_array_size];
  9. vector<char> heap_array;
  10. char *arr=stack_array;
  11. if(N>stack_array_size)
  12. {
  13. heap_array.resize(N);
  14. arr=&heap_array[0];
  15. }
  16. // use arr here
  17. }
  18.  
  19. int main()
  20. {
  21. f(20);
  22. }
Success #stdin #stdout 0.01s 2852KB
stdin
Standard input is empty
stdout
Standard output is empty