I used to run a calculation by reading from 1 txt file ("1_Hello.txt"), calculate and output by functions, and write the output into a new txt file.
But now I have 5000 txt files ("1_Hello.txt" to "5000_Hello.txt"). I want to read all 5000 txt files, calculate each txt file by functions ( variable "a" and vector "v"), and write the output of these 5000 files into a new txt file and a new excel file that contains calculated results of all 5000 input files.
Input format: id x y z
Ex: 1 9 7 5
Wanted output format: id x y z add() int_vector()
Ex: 1 9 7 5 5.5 123
How can I read 5000 txt files and write the calculated results from functions into new txt and excel files?
Any help would be appreciated.
double add(){
// do something
}
void output_vector(std::vector<int> &v) {
// do something
}
int main() {
std::vector<int> v;
double a;
ifstream in("1_Hello.txt");
in.close();
a=add();
output_vector(v);
return 0;
}