Guest User

Untitled

a guest
Dec 15th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. # include <iostream>
  2. # include <fstream>
  3. # include <cstdlib>
  4. using namespace std;
  5.  
  6. void fileInput(char inFile[20], char outFile[20]);
  7. void count (char word[64], char line [10000]);
  8. int main()
  9. {
  10.     char in[20];
  11.     char out[20];
  12.     count(in,out);
  13.  
  14.  
  15.  
  16.  
  17. }
  18. void fileInput(char inFile[20], char outFile[20])
  19. {
  20.     ifstream fin;
  21.     cout << "What is the name of the input file? ";
  22.     cin >> inFile;
  23.     fin.open(inFile);
  24.     if (fin.fail()) // If the file doesn't open i.e user unputs wrong file name
  25.     {
  26.         cout << "The File " << "\"" << inFile << "\"" << " won't open" << endl;
  27.         exit(1); // Program stops
  28.     }
  29.     cout << "What is the name of the output file? ";
  30.     cin >> outFile;
  31.     ofstream fout;
  32.     fout.open(outFile);
  33.  
  34. }
  35.  
  36. void count (char word[64], char line [10000])
  37. {
  38.     int counter = 0;
  39.     fileInput(word, line);
  40.     ifstream fin; // á ég ekki að setja eitthvað annað hérna?
  41.     fin.open(word); // og hérna, málið er að þetta fer ekki inn í loopuna (held ég :))
  42.     while(!fin.eof())
  43.     {
  44.         cin >> word;
  45.         counter ++;
  46.         cout << counter << endl;
  47.     }
  48.  
  49.  
  50.  
  51. }
  52. void copy (ifstream& in, ofstream& out)// á eftir að nota
  53. {
  54.  
  55.  
  56. }
  57.  
  58. void print (char out)
  59. {
  60.  
  61.  
  62. }
Add Comment
Please, Sign In to add comment