开发者

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

开发者 https://www.devze.com 2023-01-29 12:26 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered i开发者_如何学Pythonn its current f
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

精彩评论

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