how to declare EOF?(simple)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear g++ programers:
  I just tried a piece simple c++ code, copied from c++ primer plus book(5ed, pg221), but it failed to compile, because EOF was not declared in this scope
plz help!
Eric
------------

root@eric-laptop:/home/eric/cpppp5# g++ textin4.cpp
textin4.cpp: In function ?int main()?:
textin4.cpp:9: error: ?EOF? was not declared in this scope
root@eric-laptop:/home/eric/cpppp5# cat textin4.cpp
// textin4.cpp -- reading chars with cin.get()
#include <iostream>
int main(void)
{
  using namespace std;
  int ch;                   // should be int, not char
  int count = 0;

  while ((ch = cin.get()) != EOF)  // test for end-of-file
  {
       cout.put(char(ch));
       ++count;
  }
  cout << endl << count << " characters read\n";
  return 0;
}





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux