swapping bytes in a file in c++ [closed]
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.
- Read the file into memory
- Modify the memory
- Write the memory back to file
- Create two buffers of length 100 bytes each, say A and B.
- Read 100 bytes from file to A (assuming that the file cursor points to the beginning of the file).
- Seek to file length n-100.
- Read 100 bytes from file to B.
- Again, seek to file length n-100.
- Write 100 bytes from A to file.
- Seek to file position 0.
- Write 100 bytes from B to file.
精彩评论