全部题库 / C++ / 试题详情
单选题 C++
2014-04-23

从一个文件中读一个字节存于char c;正确的语句为(  )。

A.file.read(reinterpret_cast<const char *>(&c), sizeof(c));
B.file.read(reinterpret_cast<char *>(&c), sizeof(c));
C.file.read((const char *)(&c), sizeof(c));
D.file.read((char *)c, sizeof(c);

参考答案

B

答案解析

略

你可能感兴趣的试题

A.file.write(reinterpret_cast<const char *>(&c), sizeof(c));
B.file.write(reinterpret_cast<char *>(&c), sizeof(c));
C.file.write((char *)(&c), sizeof(c));
D.file.write((const char *)c, sizeof(c));
A.myfile.seekg(1,ios::end);    
   c=myfile.get();               
B.myfile.seekg(-1,ios::end);
   c=myfile.get();
C.myfile.seekp(ios::end,0);   
   c=myfile.get();                
D.myfileseekp(ios::end,1);
   c=myfile.get();
A.一个字符  
B.当前字符  
C.一行字符  
D.指定若干字节