Write a cc function to write entries to a file according to

Write a c/c++ function to write entries to a file according to void arr.process(in.array,N,start.index,stop-index,outfile name)
Write a c/c++ function to write entries to a file according to void arr.process(in.array,N,start.index,stop-index,outfile name)

Solution

/* Assuming an string array else a template can be used */

/* template <typename T> */ // Whereever required T can be used in place of string

/* void process(T arr[],int N,int startIndex,int stopIndex,string outFileName) */

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
using std::string;
void process(string arr[],int N,int startIndex,int stopIndex,string outFileName){

ofstream out;
   out.open(outFileName); //opening an output stream for outFileName
       for(int i = startIndex; i <= stopIndex; i++)
out << arr[i]; //writing ith element of array in the file
out.close();
}

 Write a c/c++ function to write entries to a file according to void arr.process(in.array,N,start.index,stop-index,outfile name) Write a c/c++ function to write

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site