Advertisement
NickJuelich

Untitled

Oct 12th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.  
  10.     string arr [5];
  11.     string nArr [5];
  12.     ifstream infile;
  13.     infile.open("dictionary.txt");
  14.  
  15.     if(!infile)
  16.     {
  17.         cout << "Unable to open file.";
  18.     }
  19.  
  20.     else if(infile)
  21.     {
  22.         while(!infile.eof())
  23.         {
  24.             int i = 0;
  25.             string line;
  26.             infile >> arr[i];
  27.             i++;
  28.         }
  29.     }
  30.  
  31.     string fname;
  32.     cout << "Welcome to Nick's Spell Checker!" << endl;
  33.     cout << "********************************" << endl;
  34.     cout << "Enter the name of the file that contains words to check." << endl;
  35.     cin >> fname;
  36.  
  37.     ifstream checkfile;
  38.     checkfile.open("wrong.txt");
  39.  
  40.     if(!checkfile)
  41.     {
  42.         cout << "Unable to open '" << fname << "'." << endl;
  43.     }
  44.     else if (checkfile)
  45.     {
  46.         while(!checkfile.eof())
  47.         {
  48.             int f = 0;
  49.             string nLine;
  50.             checkfile >> nArr[f];
  51.             f++;
  52.         }
  53.     }
  54.  
  55.     int x = 0;
  56.     while (x < 5)
  57.     {
  58.         if(arr[x] != nArr[x])
  59.         {
  60.             cout << endl << nArr[x] << " is spelled wrong." << endl;
  61.         }
  62.  
  63.         x++;
  64.     }
  65.  
  66.  
  67.     cout << endl << endl << "Thank you for using Nick's spell checker." << endl << endl << endl << endl << endls;
  68.  
  69.     return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement