Answers for "Read multiple files(.txt) c++"

C++
3

Read multiple files(.txt) c++

#include <sstream>
#include <iostream>
#include <string>

using namespace std;
int main()
{
	string filename;
	ostringstream ss;
	filename="data_";
	for(int i;i<2;i++)
	{
	ss << filename << i;
	FILE * f = fopen (ss.str(), "r");
			 if (NULL != f)
			 {
				 ///.....some work
			 }
			 else
			 printf ("Could not open the file\n");
	}
	return 0;
}
Posted by: Guest on June-21-2020

Browse Popular Code Answers by Language