fopen文件追加的有关问题
fopen文件追加的问题
怎么样往文件的前面追加? 而不是往最后面追加?
------解决方案--------------------
可以先另存一下文件,再重写文件,只要最后加上刚才另存的原来文件应该就可以了。
------解决方案--------------------
DWORD SetFilePointer(
HANDLE hFile,
LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh,
DWORD dwMoveMethod
);
dwMoveMethod:
FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
FILE_CURRENT Indicates that the starting point is the current value of the file pointer.
FILE_END
------解决方案--------------------
文件在硬盘上是顺序存放的,在前面追加有两种方式:
1.不改变文件的内容,把文件记录信息向前移
2.把文件的内容向后移,插入追加的信息,文件记录信息不变
第一种方式OS很难实现的哦
------解决方案--------------------
SetFilePointer 使用的是CreateFile产生的句柄
怎么样往文件的前面追加? 而不是往最后面追加?
------解决方案--------------------
可以先另存一下文件,再重写文件,只要最后加上刚才另存的原来文件应该就可以了。
------解决方案--------------------
DWORD SetFilePointer(
HANDLE hFile,
LONG lDistanceToMove,
PLONG lpDistanceToMoveHigh,
DWORD dwMoveMethod
);
dwMoveMethod:
FILE_BEGIN Indicates that the starting point is zero or the beginning of the file.
FILE_CURRENT Indicates that the starting point is the current value of the file pointer.
FILE_END
------解决方案--------------------
文件在硬盘上是顺序存放的,在前面追加有两种方式:
1.不改变文件的内容,把文件记录信息向前移
2.把文件的内容向后移,插入追加的信息,文件记录信息不变
第一种方式OS很难实现的哦
------解决方案--------------------
SetFilePointer 使用的是CreateFile产生的句柄