在第140个位置和176个位置读取长4个字节

编程入门 行业动态 更新时间:2024-10-28 14:23:19
本文介绍了在第140个位置和176个位置读取长4个字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是havinig文件. 文件大小1200 我正在通过ifstream读取文件.

Hi i am havinig file. file size 1200 i am reading the file thru ifstream.

outHdrFile.seekg(0, ios::end); long Hdrlen = outHdrFile.tellg(); ifstream::pos_type HdrPtr; HdrPtr = Hdrlen;// - headerSize; BYTE* HdrFileBuff = new BYTE[HdrBufferSize]; outHdrFile.seekg (140, ios::beg); outHdrFile.read((char*)HdrFileBuff,HdrPtr);

从第140个位置读取4个字节,并将其写入具有第140个位置的临时文件中.在第140个位置6中,我必须在那里更新6100. 请告诉我如何以最少的行数进行更新. 谢谢

reading 4 bytes from 140th postion and write that into a temp file with same position 140th .in 140th position 6 is there and i have to update 6100 there. pls tell me how to update in minimum lines. thanks

推荐答案

忘记进行这种类型的交易时要寻求的知识;这样做:
  • 读取输入文件的后N个字节(在这种情况下为140).
  • 将这些字节写入输出文件.
  • 读取后N个字节(4个). /li>
  • 修改刚刚读取的值.
  • 将修改后的值写入输出文件.
  • 重复此操作,直到复制所有数据.
  • Forget about seeking when doing this type of transction; do it this way:
    • Read the next N bytes of input file (in this case 140).
    • Write those bytes to the output file.
    • Read the next N bytes (4).
    • Modify the value just read.
    • Write the modified value to the output file.
    • Repeat until all data is copied.

更多推荐

在第140个位置和176个位置读取长4个字节

本文发布于:2023-11-29 19:10:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1647356.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:位置   字节

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!