Why do I have an OBOB error?
Code:
void get_numbers(char *data_array, int& num_amount, ifstream& fin){
int num; //used for temporary storage of a number obtained through the input stream
int index = 1; //this is to be used to begin storing data into data_array[1] below
char comma_discard; //used to disregard commas in the code file
clrscr();
while (!fin.eof()){
fin >> num;
cout << num;
//*(data_array + index) = num;
//cout << int(*(data_array + index)) << " ";
num_amount++;
index++;
fin.get(comma_discard);
cout << comma_discard;
}
getch();
} //end void get_numbers
Contents of what the input stream is connected to:
Code:
115,73,24,807,37,52,49,17,31,62,647,22,7,15,140,47,29,107,79,84,56,239,10,26,811,5,196,308,85,52,160,136,59,211,36,9,46,316,554,122,106,95,53,58,2,42,7,35,122,53,31,82,77,250,196,56,96,118,71,40,287,28,353,37,1005,65,147,807,24,3,8,12,47,43,59,807,45,316,101,41,78,154,1005,122,138,191,16,77,49,102,57,72,34,73,85,35,371,59,196,81,92,191,106,273,60,394,620,270,220,106,388,287,63,3,6,191,122,43,234,400,106,290,314,47,48,81,96,26,115,92,158,191,110,77,85,197,46,10,113,140,353,48,120,106,2,607,61,420,811,29,125,14,20,37,105,28,248,16,159,7,35,19,301,125,110,486,287,98,117,511,62,51,220,37,113,140,807,138,540,8,44,287,388,117,18,79,344,34,20,59,511,548,107,603,220,7,66,154,41,20,50,6,575,122,154,248,110,61,52,33,30,5,38,8,14,84,57,540,217,115,71,29,84,63,43,131,29,138,47,73,239,540,52,53,79,118,51,44,63,196,12,239,112,3,49,79,353,105,56,371,557,211,505,125,360,133,143,101,15,284,540,252,14,205,140,344,26,811,138,115,48,73,34,205,316,607,63,220,7,52,150,44,52,16,40,37,158,807,37,121,12,95,10,15,35,12,131,62,115,102,807,49,53,135,138,30,31,62,67,41,85,63,10,106,807,138,8,113,20,32,33,37,353,287,140,47,85,50,37,49,47,64,6,7,71,33,4,43,47,63,1,27,600,208,230,15,191,246,85,94,511,2,270,20,39,7,33,44,22,40,7,10,3,811,106,44,486,230,353,211,200,31,10,38,140,297,61,603,320,302,666,287,2,44,33,32,511,548,10,6,250,557,246,53,37,52,83,47,320,38,33,807,7,44,30,31,250,10,15,35,106,160,113,31,102,406,230,540,320,29,66,33,101,807,138,301,316,353,320,220,37,52,28,540,320,33,8,48,107,50,811,7,2,113,73,16,125,11,110,67,102,807,33,59,81,158,38,43,581,138,19,85,400,38,43,77,14,27,8,47,138,63,140,44,35,22,177,106,250,314,217,2,10,7,1005,4,20,25,44,48,7,26,46,110,230,807,191,34,112,147,44,110,121,125,96,41,51,50,140,56,47,152,540,63,807,28,42,250,138,582,98,643,32,107,140,112,26,85,138,540,53,20,125,371,38,36,10,52,118,136,102,420,150,112,71,14,20,7,24,18,12,807,37,67,110,62,33,21,95,220,511,102,811,30,83,84,305,620,15,2,108,220,106,353,105,106,60,275,72,8,50,205,185,112,125,540,65,106,807,188,96,110,16,73,32,807,150,409,400,50,154,285,96,106,316,270,205,101,811,400,8,44,37,52,40,241,34,205,38,16,46,47,85,24,44,15,64,73,138,807,85,78,110,33,420,505,53,37,38,22,31,10,110,106,101,140,15,38,3,5,44,7,98,287,135,150,96,33,84,125,807,191,96,511,118,440,370,643,466,106,41,107,603,220,275,30,150,105,49,53,287,250,208,134,7,53,12,47,85,63,138,110,21,112,140,485,486,505,14,73,84,575,1005,150,200,16,42,5,4,25,42,8,16,811,125,160,32,205,603,807,81,96,405,41,600,136,14,20,28,26,353,302,246,8,131,160,140,84,440,42,16,811,40,67,101,102,194,138,205,51,63,241,540,122,8,10,63,140,47,48,140,288,
Problem is, an extra "288," is being read in at the very end and I do not know why. Technically once that last fin.get() eats that last comma shouldn't that be eof?