I am trying to write a program which takes input from 1.yaml , 2.yaml ,3.yaml and so on for 300.yaml files one after the other i.e., my program processes the code for 1.yaml and sends the output to output.dat but I don't know how to give the next yaml file as input as I couldn't afford to write 300 freopen and close statements .
@coder777
I have written the following code for 1 yaml file and I couldn't find a method of how to change the main block of my code to the one you suggested.
Here is my code and please can you find how to change it.
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int total=0;
int noOfBalls=0;
int wicket=0;
string input,country1;
int scoreOfBall;
string Extras,variable,LB,Wide,NoBall,Total;
int f=1;
for(;(cin>>input) && f;)
{
if(input=="team:")
{
f=0;
cout<<"HI";cin>>country1;
}
}
for(;(noOfBalls<300) && (wicket <10);)
{
}
int main()
{
freopen("001.txt", "w", stdout);
for(int k=1;k<=300;++k)
{
stringstream ss;
ss << k;
string s=ss.str();
///The above 3 lines of code is used as my compiler is not able to compile to_string method
///Generally for one yaml file I would have written the following code
/** freopen("1.yaml","r",stdin);
solve();
**/
/// But now I have to open one yaml after another and apply solve function to it.
}
return 0;
}
The loop iterated well for 21 iterations only (took an execution time of 0.062sec.
But I want to iterate for at least 300 files.
The new code in main is