Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- # include <fstream>
- # include <cstdlib>
- using namespace std;
- void fileInput(char inFile[20], char outFile[20]);
- void count (char word[64], char line [10000]);
- int main()
- {
- char in[20];
- char out[20];
- count(in,out);
- }
- void fileInput(char inFile[20], char outFile[20])
- {
- ifstream fin;
- cout << "What is the name of the input file? ";
- cin >> inFile;
- fin.open(inFile);
- if (fin.fail()) // If the file doesn't open i.e user unputs wrong file name
- {
- cout << "The File " << "\"" << inFile << "\"" << " won't open" << endl;
- exit(1); // Program stops
- }
- cout << "What is the name of the output file? ";
- cin >> outFile;
- ofstream fout;
- fout.open(outFile);
- }
- void count (char word[64], char line [10000])
- {
- int counter = 0;
- fileInput(word, line);
- ifstream fin; // á ég ekki að setja eitthvað annað hérna?
- fin.open(word); // og hérna, málið er að þetta fer ekki inn í loopuna (held ég :))
- while(!fin.eof())
- {
- cin >> word;
- counter ++;
- cout << counter << endl;
- }
- }
- void copy (ifstream& in, ofstream& out)// á eftir að nota
- {
- }
- void print (char out)
- {
- }
Add Comment
Please, Sign In to add comment