fseek()函数问题

来源:百度知道 编辑:UC知道 时间:2024/05/28 10:11:36
为什么,我的程序中文件指针不能按要求指向?
#include <stdio.h>
#include <string.h>
void main()
{
FILE *fp;
char b[] = "Limin has left,I can't let you leave me.";
fp = fopen( "d:\\sy\\cc.txt" , "a" ) ;
if( fp == NULL )
{
printf( "Error!\n" );
exit(0);
}
fseek(fp,30L,0);
fwrite(b,strlen(b),1,fp);
printf( "The number has inputed!\n" );
fclose( fp );
}
没有人知道吗?? 不满足要求啊,不能任意改变文件指针啊!!!

下面的程序我修改了3个地方,也运行过了,可以.你看看
#include <stdio.h>
#include <string.h>
int main()//此处
{
FILE *fp;
char b[] = "Limin has left,I can't let you leave me.";
fp = fopen( "cc.txt" , "a" ) ;
if( fp == NULL )
{
printf( "Error!\n" );
return(0);//此处
}
fseek(fp,30L,0);
fwrite(b,strlen(b),1,fp);
printf( "The number has inputed!\n" );
fclose( fp );
return 0;//此处
}