|
LR91,选择的C USER协议:
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);
sprintf (filename, "%s//%s", new_dir, "newfile.txt");
sprintf (command, "dir /b c:// > %s /w", filename );
system(command);
lr_output_message("Created new file %s", filename);
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);
}
while(!feof(file_stream))
{
count=fread(buffer,sizeof(char),1000,file_stream);
lr_output_message("%3d read",count);
if(ferror(file_stream))
{
lr_output_message("error reading file %s",filename);
break;
}
total+=count;
}
lr_output_message("Total number of bytes read = %d",total);
if(fclose(file_stream))
lr_error_message("Error closing file %s",filename);
return 0;
}
运行时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 |
|