I study multithreading in C ++. Made a simple program to create and output a two-dimensional array. If the array has more than 50x50 elements, then the stream should work; if less, then it should work without threads. But when working with a stream, the program gives an error which is visible on the screenshot. Please tell me what is wrong. 
#include <iostream> #include <cstdlib> #include <thread> using namespace std; void arrayBig(int rowLength, int columnsLength) { int i, j; int arr[1000][1000]; for (i = 0; i <= rowLength - 1; i++) { for (j = 0; j <= columnsLength - 1; j++) { arr[i][j] = rand() % 10; } } for (i = 0; i <= rowLength - 1; i++) { for (j = 0; j <= columnsLength - 1; j++) { cout << arr[i][j] << " "; } cout << endl; } } int arrayLitle(int rowLength, int columnsLength) { int i, j; int arr[1000][1000]; for (i = 0; i <= rowLength - 1; i++) { for (j = 0; j <= columnsLength - 1; j++) { arr[i][j] = rand() % 10; } } for (i = 0; i <= rowLength - 1; i++) { for (j = 0; j <= columnsLength - 1; j++) { cout << arr[i][j] << " "; } cout << endl; } return arr[i][j]; } int main() { int columnsLength = 0, rowLength = 0; cout << "Π£ΠΊΠ°ΠΆΠΈΡΠ΅ Π΄Π»ΠΈΠ½Ρ ΠΌΠ°ΡΡΠΈΠ²Π°!\n"; cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΠ°Π·ΠΌΠ΅Ρ ΡΡΠ΄Π°: "; cin >> rowLength; cout << "ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΠ°Π·ΠΌΠ΅Ρ ΡΡΠΎΠ»Π±ΡΠΎΠ²: "; cin >> columnsLength; if ((rowLength >= 50) || (columnsLength >= 50)) { cout << "Π Π°Π±ΠΎΡΠ°ΡΡ ΠΏΠΎΡΠΎΠΊΠΈ!" << endl; std::thread aB(arrayBig, rowLength, columnsLength); if (aB.joinable()) aB.join(); } else { cout << "Π‘ΠΏΡΠ°Π²ΠΈΠΌΡΡ Π±Π΅Π· ΠΏΠΎΡΠΎΠΊΠΎΠ²!!!" << endl; arrayLitle(rowLength, columnsLength) } system("pause"); return 0; }