开发者

swapping bytes in a file in c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered i开发者_如何学Pythonn its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

assume that there is a file named "swaplt.doc" which contains more than 200bytes of data.now write a program that will encrypt the file by swapping its first 100 bytes of data with last 100 bytes.


  1. Read the file into memory
  2. Modify the memory
  3. Write the memory back to file


  1. Create two buffers of length 100 bytes each, say A and B.
  2. Read 100 bytes from file to A (assuming that the file cursor points to the beginning of the file).
  3. Seek to file length n-100.
  4. Read 100 bytes from file to B.
  5. Again, seek to file length n-100.
  6. Write 100 bytes from A to file.
  7. Seek to file position 0.
  8. Write 100 bytes from B to file.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜