Access violation writing location

I have a problem. Im testing character movement in c++ and when i compile and run this, then try to press arrow keys it says "Access violation writing location 0x011feff4.
Unhandled exception at 0x770a15de in test.exe: 0xC0000005: Access violation writing location 0x011feff4.
The program '[8404] test.exe: Native' has exited with code -1073741819 (0xc0000005).
"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#include <iostream>
#include <string>
#include <Windows.h>
#include <conio.h>

using namespace std;
void map1create(); // Function for creating the map1
void charcreate(); // Function for character creation
void movement();
void move();
void game(); // Executes all the functions

string name; // String with players name
int age; // Age of player

int iskeypressed = 0; // If a key is pressed
int didyoumove = 1; // If player moves
int prow = 1; // Player row
int pcolumn = 1; // Player column
int lrow = 1; //unused at the moment
int lcolumn = 1; //unused at the moment

int map1 [10][10]= {{0,0,0,0,0,0,0,0,0,0}, //Map grid
			        {0,5,5,5,5,5,5,5,5,0},
				    {0,5,5,5,5,5,5,5,5,0},
				    {0,5,5,5,5,5,5,5,5,0},
					{0,5,5,5,5,5,5,5,5,0},
					{0,5,5,5,5,5,5,5,5,0},
					{0,5,5,5,5,5,5,5,5,0},
					{0,5,5,5,5,5,5,5,5,0},
					{0,1,5,5,5,5,5,5,5,0},
				    {0,0,0,0,0,0,0,0,0,0}};
int main ()
{
game();
cin.get();
}

void map1create()
{
int counter = 0;
int row = 0;
int column = 0;
for (int row = 0; row < 10; row ++)
	{
	for(int column = 0; column < 10; column ++)
		{
		if(map1[row][column] == 0){cout<<"#";};
		if(map1[row][column] == 5){cout<<" ";};
		if(map1[row][column] == 1){cout<<"@";}; 
		}
	cout<< endl;
	}
}

void charcreate(){
	cout<<"What is your name? ";
	cin>> name;
	cin.ignore();
	cout<<"How old are you? ";
	cin>> age;
	cin.ignore();
}

void game(){
	int gamea = 1;
/*	charcreate();
	system("cls"); */ 
		while (gamea == 1){
	map1create();
	move();
	movement();
	system("cls");
	map1create();
	move();
	movement();
	system("cls");
		}
} // Still flickers a bit due to scrn clear

void move(){
	if(iskeypressed == 1){
		map1[prow][pcolumn] = 1;
	}
}

void movement(){

#define UP_ARROW    72
#define LEFT_ARROW  75
#define DOWN_ARROW  80
#define RIGHT_ARROW 77

	char Keypress;
	do { Keypress = _getch(); if(Keypress == -32){ Keypress = _getch();
		switch(Keypress){
			case UP_ARROW:{
				if(map1[prow-1][pcolumn] = 5){prow--; iskeypressed = 1;}
				if(map1[prow-1][pcolumn] = 0){prow++; iskeypressed = 1;}
				break;}
			case DOWN_ARROW:{
				if(map1[prow+1][pcolumn] = 5){prow++; iskeypressed = 1;}
				if(map1[prow+1][pcolumn] = 0){prow--; iskeypressed = 1;}
				break;}
			case LEFT_ARROW:{
				if(map1[prow][pcolumn--] = 5){pcolumn--; iskeypressed = 1;}
				if(map1[prow][pcolumn++] = 0){pcolumn++; iskeypressed = 1;}
				break;}
			case RIGHT_ARROW:{
				if(map1[prow][pcolumn++] = 5){pcolumn++; iskeypressed = 1;}
				if(map1[prow][pcolumn--] = 0){pcolumn--; iskeypressed = 1;}
				break;}
			}
		}
	}	while (iskeypressed == 1);
	
}		
You are using = instead of == inside the switch.
Thank you, and also when i repair it, it does not move the character. Do you see any other mistake there?
Topic archived. No new replies allowed.