What I've done so far:
1. open the file successfully
2. count the number of lines the file contains.
What I want to do:
-I want to print the first 4 lines
-skip the fifth line
-store the last 6 columns of the remaining lines in arrays so I can use them for processing.
Like I said the file is originaly in xlsx format so I used the word "columns".Can anyone help me? Thanks in advance
further use 2 [for] loops to read the lines that should be printed. within the second loop store the line in the array. And the line that should be skipped, well, read it and do nothing with it.
use stringstream to get the columns from the read lines (rows):
int main(void)
{ //opening the file
char filename[100];
ifstream inputfile;
cout<<"Enter the name of the file to be opened: ";
cin>>filename;
inputfile.open(filename, ios::in);
if(inputfile.fail())
{ cout<<"Opening"<<filename<<"for reading\n";
cout<<"--------------------------------\n";
cout<<filename<<" file cannot be opened!\n";
cout<<"Possible Errors:\n";
cout<<"1. The file does not exist.\n";
cout<<"2. The path was not found.\n";
}
else
{ cout<<"Opening"<<filename<<"for reading\n";
cout<<"--------------------------------\n";
cout<<filename<<" was opened successfully!\n";
cout<<"Do processing..Please wait...\n";
}
What do you want to do exactly? Add the data from the new file after the data from the first file, or start again with everything empty?
I'd see two main possibilities.
Either
1. Just put a while loop around the existing code
or
2. Put all the detailed code in a separate function and just call it as many times as required.