Segmentation Fault

I'm working on an ascii game, and I'm not far into it (at all) and the following code compiles with g++ just fine.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
using namespace std;
int map[15][15]={};
void newmap(){
	for (int i; i<16; i++){
		for (int j=0;j<16;j++){
			map[i][j]=0;
		}
	}
}
void printmap(){
	for (int i=0; i<16; i++){
		for (int j=0; j<16;j++){
			cout <<  map[i][j];
		}
	}
}
int main(){
newmap();
printmap();
return 0;
}

But when I drag the compiled file into the terminal it says: "segmentation fault". I googled it and it turns out that this is caused when a program tries to access access a bad variable that could corrupt memory. But I don't know what line of code is causing the issue, could someone please point me in the right direction?
You declared you maps to be of size 15, then try to access 16 elements (i and j are going from 0-15, which is 16). Specifically, anything where i >= 15 or j >= 15 is out of bounds.
Ahh, that makes more sense. Thanks for the reply.
Topic archived. No new replies allowed.