SHARE
TWEET

Untitled

a guest Aug 16th, 2017 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. using namespace std;
  5. using std::cerr;
  6. #include <cstdlib> // for exit function
  7. #include "HashTable.h"
  8.  
  9. void main ()
  10. {
  11.     HashTable<string> ht (118619);
  12.     string STRING;
  13.     ifstream infile;
  14.     infile.open ("dictionary.txt");
  15.        if(!infile) { // file couldn't be opened
  16.           cerr << "Error: file could not be opened" << endl;
  17.           exit(1);
  18.        }
  19.  
  20.     while(!infile.eof()) // To get you all the lines.
  21.         {
  22.             getline(infile,STRING); // Saves the line in STRING.
  23.             hash;
  24.             cout<<STRING; // Prints our STRING.
  25.         }  
  26.    
  27.     infile.close();
  28.     system ("pause");
  29.    
  30.     infile.open ("document.txt");
  31.        if(!infile) { // file couldn't be opened
  32.           cerr << "Error: file could not be opened" << endl;
  33.           exit(1);
  34.        }
  35.  
  36.     while(!infile.eof()) // To get you all the lines.
  37.         {
  38.             getline(infile,STRING); // Saves the line in STRING.
  39.            
  40.             cout<<STRING; // Prints our STRING.
  41.         }
  42.    
  43.     infile.close();
  44.     system ("pause");
  45. }
  46.  
  47. /*#include <iostream>
  48. using std::cerr;
  49. using std::cin;
  50. using std::cout;
  51. using std::endl;
  52. using std::string;
  53. #include <fstream>
  54. #include <string>
  55. using std::ifstream;
  56. #include <cstdlib> // for exit function
  57.  
  58. // This program reads values from the file 'dictionary.txt'
  59. // and echoes them to the display until a negative value
  60. // is read. Borrowed from Deitel & Deitel.
  61.  
  62. int main()
  63. {
  64.     ifstream indata; // indata is like cin
  65.     int num; // variable for input value
  66.     string myString;
  67.  
  68.     indata.open("dictionary.txt"); // opens the file
  69.        if(!indata) { // file couldn't be opened
  70.           cerr << "Error: file could not be opened" << endl;
  71.           exit(1);
  72.        }
  73.  
  74.     //   while ( !indata.eof() ) {cin.getline (ifstream, myString);} // keep reading until end-of-file
  75.        
  76.        indata.close();
  77.        cout << "End-of-file reached.." << endl;
  78.        return 0;
  79. }
  80. */
RAW Paste Data
Top