Advertisement
Guest User

Untitled

a guest
Oct 13th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char fileName[15];
  8.     int num,
  9.         posCount = 0,
  10.         negCount = 0,
  11.         i = 0,
  12.         p = 0;
  13.     int posArr[posCount],
  14.         negArr[negCount];
  15.    
  16.     cout << "Enter the name of the file you wish to open: " << endl << "(MUST BE 15 CHARACTERS OR LESS)" << endl;
  17.    
  18.     cin >> fileName;
  19.    
  20.     ifstream inputFile;
  21.     inputFile.open(fileName);
  22.    
  23.     inputFile >> num;
  24.    
  25.     while(num != 999)
  26.     {
  27.         if(num > 0)
  28.         {
  29.             num = posArr[posCount];
  30.             posCount++;
  31.         }
  32.         else if(num < 0)
  33.         {
  34.             num = negArr[negCount];
  35.             negCount++;
  36.         }
  37.         else
  38.             cout << "Do not enter 0 as a value." << endl;
  39.    
  40.         if (num == 999)
  41.         {
  42.             cout << "Positive Numbers:" << endl;
  43.        
  44.             for(i = 0;i < (posCount + 1);i++)
  45.             {
  46.                 cout << posArr[i] << endl;
  47.             }
  48.        
  49.             cout << "Negative Numbers:" << endl;
  50.        
  51.             for(p = 0;i < (negCount + 1);p++)
  52.             {
  53.                 cout << negArr[p] << endl;
  54.             }
  55.             inputFile.close();
  56.         }
  57.     }
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement