Reputation: 407
Iv written a program with C++ that takes 259 double numbers and then compute some attributes of these numbers. Iv generated my desired input and put it in a file called input.txt
. This file contains 1000 test cases, That means (1000*259) double numbers in a single text file. How can I run my program 1000 times and give the generated input to it?
Upvotes: 0
Views: 49
Reputation: 117856
If you write a function that processes a single line
double Compute(std::vector<double> const& nums)
{
// do something with nums
return answer;
}
Then you can use this function in a loop. Here is rough psuedocode that shows one method to do this.
int main()
{
// open your file
while (std::getline(file, line))
{
// create a std::vector<double> from line
double answer = Compute(your_vector);
}
return 0;
}
Upvotes: 3