fgets读取一行,fgetc读取一个字符,fread读取你想要的长度
FILE *fp = fopen(fileName,"r");
if (fp != NULL)
{
char buf[1024] = {0};
fgets(buf,fp);
}
fclose(fp);
用fread函数,是直接读一行的。和你描述的功能一模一样
FILE *fp;
int len=1024;
char * rdbuff;
char *ptr=null;
fp=fopen("configure.xml","r");
rdbuff=(char*)malloc();
memset(rdbuff,0,sizeof(char)*);
ptr=rdbuff;
while(fread(rdbuff,sizeof(char),1,fp)!=0&&*rdbuff!='\0')
{
ptr++;
}
printf("%s\n",rdbuff);