all blacks 0 Newbie Poster

I wan to read from multiple files and write into 1 file....the fuse_cortex_header_r function will read a file and then break the file into several file which only consist of classes...for fuse_cortex_header_w file, i would like to read all the files which have been writen by previous function and write everthing back into 1 file....it basically works as a splitter and combiner...But the write function doesnt seems working very well, i only could read 1 file and write it in 1 file, there is still 39 classes to be read and written after the 1st file..here is the code

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>


using namespace std;


void Fuse_cortex_header_r(){

    char str[99999];
    string str2, str3, str4;
    size_t pos, pos1;
    fstream file_op("c:\\Fuse_cortex.h",ios::in);
    file_op.getline(str,99999,'@');
  
    string s = str;

	for(int ctr = 1; ctr < 41; ctr++)
	{      
	
        stringstream sstrm, sstrm2, sstrm3;
        sstrm << "c:\\Fuse_cortex#" << ctr << ".txt";
        sstrm2 << "//cls#" << ctr;
        sstrm3 << "//cls*" << ctr;
        string filename = sstrm.str();
        string start = sstrm2.str();
        string end = sstrm3.str();
        pos = s.find(start);    
        str2 = s.substr (pos);
        pos1=str2.find(end);
        str4 = str2.substr(0,pos1+8);
        fstream file_op2(filename.c_str(), ios::out);
        file_op2<<str4;
        file_op2.close();
		
	}
	file_op.close();
}


void Fuse_cortex_header_w(){
	
	stringstream sstrm;
                char str[9999];

	for(int ctr = 1; ctr < 41; ctr++){


	sstrm << "c:\\Fuse_cortex#" << ctr << ".txt";
	string filename = sstrm.str();

	fstream file_op3(filename.c_str(), ios::in);
	file_op3.getline(str,9999,'@');

	string s_class = str;

	fstream file_op4("c:\\Fuse_cortex_header.txt", ios::app);
	file_op4 << s_class;

	file_op3.close();
	file_op4.close();
		
	}
	   
}
int main ()
{
    Fuse_cortex_header_r();
    cout << "Successfully Splitted "<< endl; 
    Fuse_cortex_header_w();
    cout << "Successfully Combined " << endl;
    getchar();
    return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.