physicsg 0 Newbie Poster

Hey. I have just joined and my skills in C++ are more or less no existen but still better than me trying to learn python or smth which supposedly is more adequate for the task as i am told.

Any way I have a data file which consits of observational data in the below format

Name=Observation1
DNU=
Nu=
...
% Some values %
END

Name=Observation2
DNU=
Nu=
...
% Some values %
END

This repeats for quite some time. I was wondering if it is possible to create a program to dump each of these until the respective ENDs into a new .txt file.

My attempt so far

#include <fstream>
#include <iostream>
#include <string> 
using namespace std;


int main()
{

string filename;
cout << "Which file?\n";
cin >> filename;

ifstream sourcefile;

sourcefile.open (filename".asc");

if(!indata) { // file couldn't be opened
      cerr << "Error: file could not be opened" << endl;
      exit(1);
  }

string outputname
cout << "Where to?\n";
cin >> outputname;


ofstream outputfile;

outputfile.open(outputname".txt");


do{

outputfile << sourcefile

}while(!sourcefile.eof() && size_t find_first_of="END")

Any help is greatly appreciated! Don't mind pointers to links of similiar problems to figure it out by myself if you aren't comfortable with giving a straight answer :)

Max

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.