当我使用ifstream的read函数时,如何获得实际的字节数
How to get the real number of bytes when i use read function of ifstream
代码:
ifstream in("a.jpg",ios:in|ios:binary);
char data[1024];
in.read(data,1024);
如何知道读取函数读取的实际字节数?
您想要使用gcount
,类似于以下内容:
std::streamsize bytes_read = in.gcount();
相关文章:
- 如何将字节数组元素替换为修改的十六进制 ASCII 符号?
- 基于字节数组生成静态范围整数值
- 将字节数组转换为带有字节序问题的指针
- 使用 stbi_write_png,如何将 0 和 1 的矩形字节数组转换为单色 png 文件?
- 字节数组初始化会导致 DirectX 崩溃
- 使用 swig 追加到字节数组
- C++ 替换字节数组中项的顺序
- QDataStream 读取和写入的字节数比 QFile::length() 报告要多
- 如何从保存在 Java 中C++的字节数组中读取数字?
- 如何在C++(Arduino)中将浮点数组转换为字节数组
- 将字节数组转换为多维数组
- 为什么 sizeof 在 C++ 中给出不正确的字节数?
- 如何将带有空字符的字节数组馈送到 std::iostream 中?
- C++字节数组到整数
- 将字符串转换为无符号字符数组/字节数组
- 用于 progmem 的C++和头文件压缩的 Web 文件字节数组
- mmap 中的长度是字节数还是页数?
- 如果我向一个12字节的缓冲区写入的字节数少于12,会发生什么情况
- 当我使用ifstream的read函数时,如何获得实际的字节数
- 如何在linux上获得异步套接字上可读取的字节数