fseek(文件指针,long型便宜量, 起始点);
其中起始点有3种 ,SEEK_SET表示文件首,数字为0。SEEK_CUR为文件中,数字为1。SEEK_END为文件尾,数字为2。
下边举例代码问实现将文件2中的内容复制到文件1内容的后面。
#include "stdafx.h"
#include <stdlib.h>/*为了调用system("PAUSE");*/
#include <time.h>/*为了调用time;*/
#include <stdio.h>
#include <string.h>
#include <windows.h>
int main(int argc , char* argv[])
{
char ch, filename1[50], filename2[50];
FILE *fp1, *fp2;
printf("Input filename1 :");
scanf("%s",filename1);
if((fp1=fopen(filename1,"a+"))==NULL)/*以读写的形式打开文件1*/
{
printf("Can't open filename1\n");
exit(0);
}
printf("filename1:");
ch = fgetc(fp1);
while(ch != EOF)
{
putchar(ch);