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.
At 10 posts the following advice shouldn't be something new:

PLEASE learn to use code tags, they make reading and commenting on source code MUCH easier.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

HINT: you can edit your post and add code tags.

Some formatting & indentation would not hurt either
Registered users can post here. Sign in or register to post.