Program stops working

Part of a project I am doing involves taking the information from one text file and putting it into two separate arrays. Whenever I build and run the program stops responding after I copy elements into the mpd array. It outputs the information correctly on the screen but then it stops running. Any help appreciated.

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
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <sstream>

using namespace std;

int main()

{
    ifstream inFile;
    string name[5];
    double mpd[5][7];
    string input[5][8];
    int x,y;

    inFile.open("Marathon.txt");
    cout<<"Gathering input data..."<<endl;

    for (y = 0; y < 5; y++){
        for(x = 0; x < 8; x++){
            inFile >> input[y][x];
            cout << input[y][x] << " ";
        }
    cout << " \n";
    }

    for (y = 0; y < 5; y++){
        name[y] = input [y][0];
        cout << name [y] << " \n";
    }

    for (y = 0; y < 5; y++){
        for(x = 1; x < 8; x++){
        stringstream sso;
        sso << input[y][x];
        sso >> mpd[y][x];
        cout << mpd[y][x] << " ";
        }
    cout << "\n";
    }



    inFile.close();

    return 0;
}


This is Marathon.txt file if you needed to know:
Jason 5 3 2 1 3 2 1
Samantha 10 1 1 1 5 1 1
Ravi 3 3 3 3 3 3 3
Sheila 1 2 3 1 2 3 1
Ankit 2 2 2 5 2 2 2
1
2
3
4
5
6
7
8
9
10
11
	for (y = 0; y < 5; y++)
	{
		for (x = 1; x < 8; x++)
		{
			stringstream sso;
			sso << input[y][x];
			sso >> mpd[y][x];
			cout << mpd[y][x] << " ";
		}
		cout << "\n";
	}
x goes from 1 to 8, but for `mpd' the valid index goes from 0 to 7.
So you are accessing out of bounds and invoking undefined behaviour.
Change it to mpd[y][x-1]
Thanks, its not crashing now and I had to play with it a little bit more but its working the way I want it to.
Topic archived. No new replies allowed.