if((file_stream=fopen(filename,"r"))==NULL)
{
lr_error_message("can not open %s",filename);
return -1;
}
for(i=1;i<10;i++)
{
if (fgets(line, 100, file_stream) == NULL)
lr_output_message("fgets error" );
else
lr_output_message( "The first line is /"%s/"", line);
}
运行时Replay Log中报下面这4个错误:
Action.c (33): undeclared identifier `s'
Action.c (33): operands of % have illegal types `pointer to char' and `int'
Action.c (33): operands of / have illegal types `int' and `pointer to char'
Action.c (33): type error in argument 1 to `lr_output_message'; found `int' expected `pointer to char'
c:\\documents and settings\\lilei\\local settings\\temp\\noname4\\\\combined_noname4.c (4): 4 errors, not writing pre_cci.ci作者: fish_yy 时间: 2008-7-6 17:18
这个问题你错在转义字符是\"而不是/",所以报错。
看下面的代码:
Action()
{
int count,total=0,i;
char buffer[1000];
long file_stream;
char filename[1024], command[1024],line[100];
char new_dir[] = "C://test";
if (mkdir(new_dir))
lr_output_message("Create directory %s failed", new_dir);
else
lr_output_message("Created new directory %s", new_dir);
if((file_stream=fopen(filename,"r"))==NULL)
{
lr_error_message("can not open %s",filename);
return -1;
}
for(i=1;i<10;i++)
{
if (fgets(line, 100, file_stream) == NULL)
lr_output_message("fgets error" );
else
lr_output_message( "The first line is \"%s\"", line);
}