cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
Multidimensional array complies but fail
Multidimensional array complies but fails to run
May 21, 2013 at 1:43am UTC
TheGingerKid
(4)
#include <iostream>
using namespace std;
void arrays(string location[19][19]);
string location[19][19];
int main()
{
arrays(location); //This simple function fails.
//Its probably an easy fix, but i can't find it.
}
void arrays(string location[19][19])
{
for (int x = 0; x < 20; x++)
for (int y = 0; y < 20; y++)
location[x][y] = "-";
}
Last edited on
May 21, 2013 at 2:19am UTC
May 21, 2013 at 2:30am UTC
TheGingerKid
(4)
Fix:
Your an idiot (this is how i expected you guys to reply to me). Change all of the 19s to 20s. Done.
Reason:
location[x][y] runs until location[19][0]. location[19][0] would be the 20th value of the array, but the array is set for [19] values.
Last edited on
May 21, 2013 at 2:43am UTC
Topic archived. No new replies allowed.