The goal of this program is to take the input from quote and put it into 'darray.' Then reverse it and output it to a
The goal of this program is to take the input from "quote" and put it into 'darray.' Then reverse it and output it to a file in reverse order with one word per line.
reverse_file.cpp
#include
int main(int argc, char * argv[]) {
// check program launched with correct number of arguments
// open input file and check if opened correctly // return error code if failed
// open output file and check if opened correctly // return error code if failed
// darray to hold words read in from file (do not modify) darray<:string> words(1);
// read each word into darray (grow array with reset_capacity as needed)
// write each word to output file (one on a line) // in the revese order they were read from input file
// close input/output file or let // them go out of scope to close
return 0; }
array.hpp
#ifndef CS2_ARRAY_HPP #define CS2_ARRAY_HPP
#include
template
private: type * data; int cap;
darray(int new_cap, const darray
public:
// constructors darray() : data(nullptr), cap(0) {} darray(int); darray(const darray
// destructor ~darray();
// swap void swap(darray
// subscript type operator[](int) const; type & operator[](int);
// capacity() int capacity() const;
// reset capacity void reset_capacity(int new_cap);
};
template
template
template template int smaller = new_cap; if(rhs.cap for(int i = 0; i } template int temp_cap = cap; cap = rhs.cap; rhs.cap = temp_cap; type * temp_data = data; data = rhs.data; rhs.data = temp_data; } template template template template template /* int * temp_data = new int[new_cap]; for(int i = 0; i = cap) { temp_data[i] = 0; } else { temp_data[i] = data[i]; } } delete [] data; data = temp_data; cap = new_cap; */ } template template for(int i = 0; i > ar[i]; } return in; } #endif quote.txt The major cause of the software crisis is that the machines have become several orders of magnitude more powerful! To put it quite bluntly: as long as there were no machines, programming was no problem at all; when we had a few weak computers, programming became a mild problem, and now we have gigantic computers, programming has become an equally gigantic problem.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started