Application Crashing

Hello, i am a major beginner to c++ but i know a few basic things so im trying to make something random.
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
118
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>

using namespace std;


int main()
{
	string Name;
	string Class;
	string Strength;
	string Agility;
	string Intelligence;
	string Skill[4];
	string AttackRange;
	string Movespeed;
	string Affiliation;
	string Role;
	string SK1[4];
	string SK2[4];
	string SK3[4];
	string SK4[4];
	string Range[3];
	string Duration[3];
	string Cooldown[3];
	string ManaCost[3];

	cout << "Summon name?: ";
	getline(cin, Name);

	cout << "Class?: ";
	getline(cin, Class);

	cout << "Strength?:  ";
	getline(cin, Strength);

	cout << "Agility?: ";
	getline(cin, Agility);

	cout << "Intelligence?: ";
	getline(cin, Intelligence);

	cout << "Learns Skills?: ";
    getline(cin, Skill[0]);

	cout << "Attack Range?: ";
	getline(cin, AttackRange);

	cout << "Movement Speed?: ";
	getline(cin, Movespeed);

	cout << "What is his Affiliation?: ";
	getline(cin, Affiliation);

	cout << "What is his role?: ";
	getline(cin, Role);

	cout << "Skill 1 Description";
	getline(cin, Skill[1]);

	cout << "Level 1: ";
	getline(cin, SK1[0]);

	cout << "Level 2: ";
	getline(cin, SK1[1]);

	cout << "Level 3: ";
	getline(cin, SK1[2]);

	cout << "Level 4: ";
	getline(cin, SK1[3]);

	cout << "Level 5: ";
	getline(cin, SK1[4]);

	cout << "Range: ";
	getline(cin, Range[0]);

	cout << "Duration: ";
	getline(cin, Duration[0]);

	cout << "Cooldown: ";
	getline(cin, Cooldown[0]);

	cout << "Mana Cost: ";
	getline(cin, ManaCost[0]);


	cout << "INTRODUCTION\n";
	cout << Name << ", " << Class << endl << endl;
	cout << "Strength: " << Strength << endl;
	cout << "Agility: " << Agility << endl;
	cout << "Intelligence: " << Intelligence << endl << endl;
	cout << "Learns Skills: " << Skill[0] << endl << endl;
	cout << "Attack Range of: " << AttackRange << endl;
	cout << "Movement Speed of: " << Movespeed << endl << endl;
	cout << "HERO INFORMATION" << endl << endl;
	cout << "Affiliation: " << Affiliation << endl;
	cout << "Role: " << Role << endl << endl;
	cout << "HERO ABILTIES" << endl;
	cout << "Skill 1" << endl;
	cout << Skill[1] <<endl;
	cout << "Level 1 - " << SK1[0] << endl;
	cout << "Level 2 - " << SK1[1] << endl;
	cout << "Level 3 - " << SK1[2] << endl;
	cout << "Level 4 - " << SK1[3] << endl;
	cout << "Level 5 - " << SK1[4] << endl;
    cout << "Range: " << Range[0] << endl;
    cout << "Duration: " << Duration[0] << endl;
    cout << "Cooldown: " << Cooldown[0] << endl;
    cout << "Mana Cost: " << ManaCost[0] << endl;



	system("PAUSE");
}


at the Level 5 part of that code, the SK[4] part, it crashes and i have no idea why...i know the code i made is terrible and messy but i still need to understand why its not working =D
when you declare an array, string SK1[4]; for example, it means that there are 4 elements in the string: SK1[0], SK1[1], SK1[2] and SK1[3]. SK1[4] would be a 5th element which does not exist. Thus program crashes.
learn to use a debugger,and you will find a debugger is really necessary and efficient for c++ programmers.
Ty hamsterman, i watched a video tutorial on arrays and the only thing they said was 0 is the first part of the array.

Saturnman i use Microsoft visual c++ 2010 express i think that has a debugger but it gave me an error code i had no idea what it meant, a bunch of numbers and stuff.
Topic archived. No new replies allowed.