I am getting an exception when I run this code. It built successfully.

I am getting an exception when I run this code. It built successfully.
I think the exception is occuring during the execution of the void showgameboard function. Can someone help me figure out why this exception is being thrown.

Thank you!!!

#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;



void showgameboard(string arr[][5], int size)
{
cout << "Game Board:" << endl;
for (int i = 0; i < size; i++)
{
for (int j = 0; j < 5; i++)
{
cout << arr[i][j] << endl;
}
}
}





int main()

{
const int rows = 2;
const int cols = 5;
string zep[rows][cols] = { { "X", "X", "X", "X", "X"},
{"", "", "X", "", "" } };

showgameboard(zep, rows);


return (0);
}
Look VERY carefully:
for (int j = 0; j < 5; i++)
These errors are easier to spot when you give your variables more meaningful names like row or col.
Topic archived. No new replies allowed.