im not familiar with ifstream and haven't found any examples of the method i need so im asking for assistance
ive been building a code and my client doesn't want it to be preset data anymore , wants to be able to read from the dat file, so they can change the dat file to suit them for volunteers of a different year, ijust need a quick code to patch this , and it would be a big help
all i need is a short infile code that will read the months 1 data numbers into a array , then read months 2 data numbers into another array, then months 3 data numbers into a final array
(the code was original a preset data built into it , so now i dont want to change to much so it still functions correctly)
i would like to read the months 1,months 2, and months 3 data into 3 different arrays so the arrays would be like so in the program
int m1[]={1,2,3,4,5,6,7,8,9,10,11,12};
int m2[]={12,12,10,9,8,7,6,5,4,3,2,1};
int m3[]={6,5,4,3,2,1,7,8,9,10,11,12};
im then going to compare these arrays in a compare function i created to all permutations of 12!(months 1-12 basically)
this will take a while to run but it will find the best possible set of months for the volunteer groups.
the code has a linked list system class and a class item which is a client of system class. the two classes will allow me to compare an array v[]={1,2,3,4,5,6,7,8,9,10,11,12}
permute v[], which is 12!
compare v[] to m1 if matching elements add 3
compare v[] to m2 if matching elements add 2
compare v[] to m3 if matching elements add 1
if no match add zero
return score
scores will be compared and then cout best score and best permutation
all i need is a short infile code that will read the months 1 data numbers into a array , then read months 2 data numbers into another array, then months 3 data numbers into a final array
1 2 3 4 5 6 7 8 9 10
int arr[3][12];
std::ifstream DataFile ("data.txt");
for(unsigned ai = 0; ai < 3; ++ai)
{
for(unsigned mi = 0; mi < 12; ++mi)
{
DataFile >> arr[ai][mi];
}
}