Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. /*
  2. File:           P607N4.cpp
  3. Description:    Reads in a file and prints every other character
  4. Programmer:     Shrimant Saxena
  5. */
  6.  
  7. #include <iostream>
  8. #include <fstream>
  9. #include <cstdlib>
  10. using namespace std;
  11.  
  12.  
  13.  
  14. int main()
  15. {
  16.  
  17.     char charvar;
  18.     ifstream inFile("test.dat");
  19.     if (inFile.fail() )
  20.     {
  21.         cout << "The file failed to open.";
  22.         exit(1);
  23.     }
  24.     while (!inFile.eof())
  25.     {
  26.         inFile.ignore(1);
  27.         inFile.get(charvar);
  28.         cout << charvar << " ";
  29.         inFile.peek();
  30.  
  31.     }
  32.     system("pause");
  33.     return 0;
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement