Faced with an error:
Run-Time Check Failure # 2 - Stack around the variable 'C' was corrupted.
It is displayed in the debugger and indicates the last function, saying that something is wrong with it. Please help.
Code:
#include "pch.h" #include <iostream> using namespace std; void ini(int arr[5][5]); void vivid(int arr[5][5]); void vividpod(int arr[5][5]); int main() { int arr[5][5]; ini(arr); vivid(arr); vividpod(arr); system("pause"); return 0; } void ini(int arr[5][5]) { for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { arr[i][j] = rand() % 10; } } } void vivid(int arr[5][5]) { for (int i = 0;i < 5;i++) { for (int j = 0;j < 5;j++) { cout << arr[i][j] << "\t"; } cout << endl; } } void vividpod(int arr[5][5]) { int pod; int C[4]; cout << "\n"; for (int i = 0; i < 4; i++) { pod = arr[4][i]; C[4] = pod; cout << C[4]; cout << endl; } }