the program does not sort all the information into its respective variable array. and for some reason when i run the program and select option 1 by pressin'1'
it just prints the entire line in the program.
#include <iostream>
#include <string>
#include <fstream>
usingnamespace std;
int main()
{
//declaring the variables
int i = 0;
int Option = 0;
string Date[2] = {};
string RegionalCop[2] = {};
char Typeog[2] = {};
double Weightin[2] = {};
double Weightout[2] = {};
//asking the user to enter and option
cout<<"Please choose an option:\n1.Option1\n2.Option2\n3.Option3\n4.Option4"<<endl;
cin>>Option;
//association the object logs with the file named Data.txt
ifstream Logs;
Logs.open("Data.txt");
if(!Logs.is_open()){cerr<<"Sorry file could not be opened";}//error message if file is not opened
else{
for ( ; i<3; i++){//for loop to read all the contents of the file
//storing all the information in the appropriate array
Logs>>Date[i];
Logs.ignore(1);
Logs>>RegionalCop[i];
Logs.ignore(1);
Logs>>Typeog[i];
Logs.ignore(1);
Logs>>Weightin[i];
Logs.ignore(1);
Logs>>Weightout[i];
//selection statement is user chooses option 1
if (Option == 1){
//if user chooses option 1 all the contentes of the file will be place in a table under its category and then displayed on the screen
cout<<"Date\tRegional Corporation\tTypeofGarbage\tweightin\tweightout"<<endl<<Date[i]<<endl<<RegionalCop[i];
//cout<<" "<<endl;
//cout<<" "<<endl;
//cout<<""<<endl;
//cout<<""<<endl;
}//endif
break;
}
}
return 0;
}