64,654
社区成员
发帖
与我相关
我的任务
分享
// A height for each vertex
std::vector<BYTE> in( _numVertices );
std::ifstream inFile(fileName.c_str(), std::ios_base::binary);
if( inFile == 0 )
return false;
inFile.read(
(char*)&in[0], // buffer
in.size());// number of bytes to read into buffer
inFile.close();
_Myt& __CLR_OR_THIS_CALL read(_Elem *_Str, streamsize _Count)
{
return _Read_s(_Str, (size_t)-1, _Count);
}
basic_istream::_Read_s
Reads a specified number of characters from the stream and stores them in an array.
basic_istream<Elem, Tr>& _Read_s(
char_type *_Str,
size_t _Str_size,
streamsize _Count
);
Parameters
_Str
The array in which to read the characters.
_Str_size
The size of _Str. //显然这里的_Str_size表示_Str的大小
_Count
The number of characters to read.
// basic_istream__Read_s.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
int main()
{
const int c_size = 10;
char c[c_size];
int count = 5;
cout << "Type 'abcde': ";
cin._Read_s(&c[0], c_size, count);
c[count] = 0;
cout << c << endl;
}