#include <iostream>
using namespace std;
using std::cerr;
using std::cout;
using std::endl;
#include <sstream>
#include <string>
#include <fstream>
using std::ifstream;
#include <cstdlib>
// for exit function
// This program reads values from the file '1.txt'
// and echoes them to the display until a negative value
// is read.
int main()
{
ifstream indata;
char num;
int sara=0,ri=0,sat=0,ha=0;
int some_int=1;
ostringstream buffer;
buffer << some_int;
string s1 =buffer.str();
char s[]=".txt";
strcat(s1,s); //giving error while copmiling
indata.open(s1); // opens the file
if(!indata) { // file couldn't be opened
cerr << "Error: file could not be opened" << endl;
exit(1);
}
indata >> num;
while ( !indata.eof() ) { // keep reading until end-of-file
indata >> num;
switch(num){
case 'a':sara+=1;break;
case 'b':ri+=1;break;
case 'c':sat+=1;break;
case 'd':ha+=1;break;}
// sets EOF flag if no value found
}
indata.close();
cout<<sara<<endl<<ri<<endl<<sat<<endl<<ha;
cout << "End-of-file reached.." << endl;
cin.get();
return 0;
}
this program giving error while concatenation of two string in which s1 has been changed from in type to string.... main purpose of doing this to handle multiple files in my src folder by changing s1.....plz help why giving error