Arrays Problem

Jun 15, 2017 at 2:02am
Hi,
My program is supposed to print from the input file (My array size is 10).But everytime I run the program it gives me warning massage saying the program has stopped working. Can someone please explain what is going on with my code?
Thank you for your time!

Header File:
#include <iostream>
#include <fstream>
#include <string>

using std::ifstream;
using std::ofstream;
using std::istream;
using std::ostream;
using std::string;
using std::cout;
using std::cin;
using std::endl;

const int LAB=10;

void readI( string input, string output );

Main File:
# include "try.h"

int main()
{
readI( "input1.txt", "output1.txt");
}

Body:
#include "try.h"

void readI( string input, string output )
{
int Checking[LAB];
int count=0;
ifstream in(input);
ofstream out(output);

int numbers;
out<<"Index\t"<<"Value"<<endl;
in>>numbers;

while (!in.fail())
{
Checking[count]=numbers;
count++;

in>>numbers;
}

for (int i=0; i<10; i++)
{
out<<i<<"\t"<<Checking[i]<<endl;
}

}


}


My Input File:
4
-13
-12
-0
-7
3
-11
-11
-12
7
14
-0
-2
5
78
78
2
45
2
44
56
76
8
99
07
34
22
34
56
7
8
5
3
3
24
56
7
8
45
-7
87
89
67


The Output I am getting:

Index Value
0 4
1 -13
2 -12
3 0
4 -7
5 3
6 -11
7 -11
8 -12
9 7
Jun 15, 2017 at 3:17am
Jun 15, 2017 at 3:59am
This one is different. I used the for loop outside the while loop and it did not give me any garbage data. So, I wanted to make sure why the program stopped here unlike my other post. That post is all about garbage data. So, I need a explanation for it.
Last edited on Jun 15, 2017 at 4:01am
Jun 15, 2017 at 10:04am
No, it's the same base garbage, with even worse problems than the code in the linked topic. I suggest you stick with the other topic.

Jun 17, 2017 at 5:14pm
@Jib- Thanks for your suggestions. I managed to solve it.
Topic archived. No new replies allowed.