Please advice me what could be a potential solution for the same. Its a bit urgent so if feasible a model code would be extremely helpful as I am new to programming.
or, similarly,
make an array of output files and open them all.
then read the main file line by line.
write the line you read to array[first_letter - 'A']
close all files. done.
roughly
1 2 3 4 5 6 7 8 9 10 11 12 13 14
ifstream infile(filename);
ofstream outfiles[3];
outfiles[0].open("A.csv", ios::app);
outfiles[1].open("B.csv", ios::app);
outfiles[2].open("C.csv", ios::app);
string s;
while(getline(infile,s))
{
outfiles[(int)(s[0]-'A')] << s << endl; //I am assuming the first letter is A/B/C
}
outfiles[0].close();
outfiles[1].close();
outfiles[2].close();