这不能通过 >> 运算符实现吗?
资料来源:
http://en.cppreference.com/w/cpp/io/basic_istream/operator_gtgt http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
's' 的值保持不变:它似乎没有从输入流中获取任何数字。
vector<signed short> CReadFileTest::ReadIntegersFromFile( const char * filename )
{
ifstream ifs(filename, ifstream::in, ifstream::binary);
vector<signed short> vec ;
if (ifs)
{
signed short s ;
while (!ifs.eof())
{
ifs >> s;
vec.push_back(s);
}
ifs.close();
}
return vec;
}