共用方式為


char_traits::not_eof

測試字元不是檔案結尾 (EOF) 字元也不是 EOF。

static int_type not_eof( 
   const int_type& _Ch 
);

參數

  • _Ch
    表示為 int_type 的字元會測試是否為 EOF 字元。

傳回值

如果字元 int_type 不等於 EOF 字元,該字元的 int_type 表示測試。

如果字元 int_type 值 EOF 與 int_type 值相等,然後 false

範例

// char_traits_not_eof.cpp
// compile with: /EHsc
#include <string>
#include <iostream>

int main( ) {
   using namespace std;

   char_traits<char>::char_type ch1 =  'x';
   char_traits<char>::int_type int1;
   int1 = char_traits<char>:: to_int_type ( ch1 );
   cout << "The char_type ch1 is " << ch1
        << " corresponding to int_type: " 
        << int1 << "." << endl;
   
   // EOF member function
   char_traits <char>::int_type int2 = char_traits<char>::eof ( );
   cout << "The eofReturn is: " << int2 << endl;

   // Testing for EOF or another character
   char_traits <char>::int_type eofTest1, eofTest2;
   eofTest1 = char_traits<char>::not_eof ( int1 );
   if ( !eofTest1 )
      cout << "The eofTest1 indicates ch1 is an EOF character."
              << endl;
   else
      cout << "The eofTest1 returns: " << eofTest1 
           << ", which is the character: " 
           <<  char_traits<char>::to_char_type ( eofTest1 )
           << "." << endl;

   eofTest2 = char_traits<char>::not_eof ( int2 );
   if ( !eofTest2 )
      cout << "The eofTest2 indicates int2 is an EOF character." 
           << endl;
   else
      cout << "The eofTest1 returns: " << eofTest2 
           << ", which is the character: " 
           <<  char_traits<char>::to_char_type ( eofTest2 ) 
           << "." << endl;
}
  

需求

標頭:<string>

命名空間: std

請參閱

參考

char_traits 結構