Small C++ code : Read & Write file


// reading word by word
ifstream ifile(filename);
vector<string> words
copy(istream_iterator<string>(ifile),
         istream_iterator<string>(),
         back_inserter(words));
ifile.close();

//writing a vector  to file
ofstream outfile;
vector<string> lines;

outfile .open(filename,ofstream::out | ofstream::app);
copy(lines.begin(),
lines.end(),
ostream_iterator<string>(outfile,"\n"));
outfile.close();


1 comment:

  1. It is most commonly used for constructing airframes, landing gears, and some engine components. Cast iron is a lot simpler to machine than different tougher metals like metal and is used mainly to make pots, pans, and different cookware. This Tool Steel has been in use since the that} early 1900s and has turn into some of the popular high-carbon device steels. A2 is a water hardening device metal that features CNC machining glorious put on resistance together with good toughness and durability. CNC Lathes usually solely have two main motions with one stationary device that strikes linearly along X and Y while also having the workpiece spinning round.

    ReplyDelete

would you like it. :)