我在这里找到了以下代码,并试图编译它以学习一些编程:
#include <fstream>
#include <cerrno>
#include <stdexcept>
#include <cstring>
#include <vector>
int main() {
// Which disk?
char diskName[] = "/dev/sda";
std::string diskError = std::string() + diskName + ": ";
// Open device file
std::ifstream disk(diskName, std::ios_base::binary);
if(!disk)
throw(std::runtime_error(diskError + std::strerror(errno)));
// Seek to 54321'th sector
disk.seekg(512 * 54321);
if(!disk)
throw(std::runtime_error(diskError + std::strerror(errno)));
// Read in one sector
std::vector<char> buffer(512);
disk.read(&buffer[0], 512);
if(!disk)
throw(std::runtime_error(diskError + std::strerror(errno)));
}
编译器在以下行抱怨:
#include <fstream>
错误信息是:
找不到“fstream”文件
我需要下载一些库吗?