Help reading a file and writing out to a file

HI, what my program is supposed to entail is that I am supposed to read a text file, then take the words from that file and make another text file through ofstream and show the number of characters in the file and get the number of characters of largest and smallest word.
Here is what I have so far.
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
const int MAXCHAR = 80;

void getinputfile(ifstream & file, char *filename);
void getoutputfile(ofstream & file, char *filename2);
int main(void)
{
ifstream inputfile;
ofstream outputfile;
string word;
int count = 0;
int largest = 0, smallest = 1000;
char fname[MAXCHAR], inputchar = ' ';
getinputfile(inputfile, fname);


while (inputfile.get(inputchar)){
cout << (char)toupper(inputchar);
}




getoutputfile(outputfile, fname);
outputfile << inputchar;

inputfile.close();
outputfile.close();
return 0;
}
void getinputfile(ifstream & file, char *filename){
cout << "Please enter an input file name that ends with (.txt)\n";
cin >> filename;
file.open(filename);

while (!file.is_open()){
cout << "Invalid file name, please re-enter.\n";
cin >> filename;
cout << filename;
file.open(filename);
}
}
void getoutputfile(ofstream & file, char *filename2){
cout << "\n\nPlease enter an output file name that ends with (.out)\n";
cin >> filename2;
file.open(filename2);
while (!file.is_open()){
cout << "Invalid file name, please enter re-enter.\n";
cin >> filename2;
file.open(filename2);
}
}
you can read the input file word by word but check if the word ends in punctuation like , ! etc. If so, strip these off and then send this word to the output file, keeping a running tab on the largest and smallest word size and update these tabs each time you have a new max/min (the min will probably floor at 1 pretty soon). the theoretical limits to size would be 0 and std::string::max_size() and use std::size_t for the sizes' datatype
Topic archived. No new replies allowed.