#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
char * ReadSpeacialLine(int i)
{
char filename[] = "test.c"; //文件名
FILE *fp;
int WhichLine=i; //指定要读取哪一行
int CurrentIndex=0; //当前读取的行
char StrLine[1024]; //每行最大读取的字符数,可根据实际情况扩大
if((fp = fopen("D:/rfdsp_sub6g.dump","r")) == NULL) //判断文件是否存在及可读
{
printf("error!");
return NULL;
}
while (!feof(fp))
{
/*
if (CurrentIndex==WhichLine)
{
fgets(StrLine,1024,fp); //读取一行
printf("%s", StrLine); //输出
return StrLine;
}
*/
fgets(StrLine,1024,fp); //读取一行,并定位到下一行
if (*(StrLine +10 ) =='g' && *(StrLine +13 ) =='d' && *(StrLine +16 ) =='C' ) {
printf("%s", StrLine); //输出
break;
}
CurrentIndex++;
//printf("123=%d\n",CurrentIndex);
//printf("***%c\n",*(StrLine+14));
//printf("%s", StrLine); //输出
}
fclose(fp); //关闭文件
return NULL;
}
int main()
{
ReadSpeacialLine(14) ;
return 0;
}