Advertisement
blainebrown

Untitled

Oct 30th, 2011
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. fstream dataFile, inFile;
  10. ofstream outFile;
  11.  
  12. string checkThis, againstThis;
  13.  
  14. vector<string> dataFileWords;
  15. vector<string> inFileWords;
  16. int checkWords = 0;
  17. // string newFile;
  18. int line = 0;
  19.  
  20. // cout << "Enter the file name (including .txt): ";
  21. // cin >> newFile;
  22.  
  23.  
  24.  
  25. dataFile.open("data.txt");
  26. // inFile.open(newFile.c_str());
  27. inFile.open("inFile.txt");
  28. outFile.open("test.txt");
  29.  
  30. if(!dataFile)
  31. {
  32. cout << "Error. File not found." << endl;
  33. system("pause");
  34. return 1;
  35. }
  36. if(!inFile)
  37. {
  38. cout << "Error. File not found." << endl;
  39. system("pause");
  40. return 1;
  41. }
  42. // outFile << "test";
  43.  
  44.  
  45.  
  46. while(!dataFile.eof())
  47. {
  48. dataFile >> dataFileWords[checkWords];
  49. checkWords++;
  50. }
  51.  
  52. for(checkWords; checkWords > -1; checkWords--)
  53. {
  54. cout << dataFileWords[checkWords] << endl;
  55. }
  56.  
  57.  
  58. /*
  59. while(!inFile.eof())
  60. {
  61. inFile >> againstThis;
  62. line++;
  63. if(checkThis == againstThis)
  64. {
  65. cout << "Don't use " << checkThis << endl;
  66. cout << "Line " << line << endl;
  67. }
  68. else
  69. {
  70. cout << checkThis << " != " << againstThis << endl;
  71. }
  72. }
  73. */
  74.  
  75. dataFile.close();
  76. inFile.close();
  77. outFile.close();
  78.  
  79. system("pause");
  80. return 0;
  81. }
  82.  
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement