Source Keeps Crashing

Just Practicing Arrays but my source keeps crashing with this program. Why?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  #include<iostream>
#include<string>
#include<iomanip>
#include<fstream>
#include<math.h>
using namespace std;

int main ()
{
	int MilesPerDay, TotalMilesPerWeek;
	int LCV;
	string Names[4];
	for (LCV = 1; LCV <= 4; LCV++)
	{
		cout<<"Enter Name: ";
		cin>>Names[LCV];
	}
	for (LCV = 1; LCV <= 4; LCV++)
	{
		cout<<"Name["<<LCV<<"]: "<<Names[LCV]<<endl;
	}
	return 0;
}
valid indexes are from 0 to size-1
in your case: 0, 1, 2, 3.
Thank you! I did not know that. If you have any time to spare for one more question, how would I store the value of a First and Last name since cin does not work.
Last edited on
closed account (48T7M4Gy)
You need to use the getline function http://www.cplusplus.com/reference/string/string/getline/?kw=getline
Thank you all for your help.
Topic archived. No new replies allowed.