Advertisement
JeffBobbo

Untitled

Mar 26th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. // istream::get example
  2. #include <iostream>     // std::cin, std::cout
  3. #include <fstream>      // std::ifstream
  4.  
  5. int main () {
  6.   char str[256];
  7.  
  8.   std::cout << "Enter the name of an existing text file: ";
  9.   std::cin.get (str,256);    // get c-string
  10.  
  11.   std::ifstream is(str);     // open file
  12.  
  13.   while (is.good())          // loop while extraction from file is possible
  14.   {
  15.     char c = is.get();       // get character from file
  16.     if (is.good())
  17.       std::cout << c;
  18.   }
  19.  
  20.   is.close();                // close file
  21.  
  22.   return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement