we just started a new topic in class of arrays, he gave us an explanation and it was very foggy, but now i got home to do my program i can not even figure out what is going on. Any help you can give would be great.
The program we had to write is as follows:
Write a program that will read in an unknown number(not more than 40) of dates from a text file in the form mm/dd/yyyy. In orger to sort them chronologically, the program must convert the date into the form yyyymmdd. After sorting, reconvert the date back to its original format and display the list of dates in sorted order from old to recent.
This is what I have so far of my somewhat understanding of the lecture, as you can tell I am very confused;
int main()
{
time_t t;
time(&t);
yl;
cls;
int count = 0;
string date [40];
int number [50];
int j, i;
for (i=0; i<40; i++)
{
date [i] = "";
number [i] = 0;
}
if (!infile)
{
cout << "An error has occurred while opening file" << endl;
print << "An error has occurred while opening file" << endl;
exit (1);
}
while (!infile.eof())
{
infile >> date [i];
for (i=0; i<40; i++)
cout << date << endl;
}
}
I am very confused with what is going on and I want to know the understanding and explanation to what is going on within this program and the understanding behind arrays.
Any help with the program and places where I can read or just a good brief explanation to what is going on in arrays, and how I can understand how to write this program.
Thank You very much for your assistance