Поделиться через


char_traits::not_eof

Проверяет, является ли символ знака конца файла (EOF) или EOF.

static int_type not_eof(
   const int_type& _Ch
);

Параметры

  • _Ch
    Символ, представленный в виде int_type для проверки, является ли знак EOF.

Возвращаемое значение

Представление int_type проверянного знака, если int_type символов не равно int type из знака EOF.

Если значение 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 Struct