简体   繁体   中英

What is the most efficient way to read from the end of a file in c++? (Parsing last 128 bits in a file)

我可以想到一些快速读取最后128位的方法,但哪种方式最简单,最有效?

Jump to the end and read:

char buf[16];

std::ifstream infile("thefile.bin", std::ios::binary);
infile.seekg(16, std::ios::end);

if (!infile || !infile.read(buf, 16))
{
    // error! Maybe die.
}

// process buf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM