Code not working when using high size arrays

Greetings,
Maybe this question is more about visual studio or c++ limits but I am programming in CUDA (as a beginner) and maybe this has happenned to some of you.

For example I have this simple code:

#include <iostream>
#include <cmath>
#include <fstream>
#include "cuda.h"  
#include "math.h"
#include <cstdio>
#include <stdlib.h>
#include <chrono> 

int main(void) {
	using namespace std;
	
	double P[100][4 * 99 * 2] = { 0 };
	double P2[100][4 * 99 * 2] = { 0 };
	cout << "hi"<<endl;
}

Ignore the libraries used. The matter is that when I defined just P the code shows Hi at its execution but when I define P2 it doesn’t. Do you know why?. As I know I am not exceding the maximum array size that C++ or CUDA can handle.

I am programming in Visual Studio.

Thank you for your help.

You are overrunning the stack space.

Create your arrays as dynamically allocated on the heap instead. You could do this with new or std::vector, for example.