Home > Back-end >  I want to change the contents of the file read out and save to the structure, when finished the firs
I want to change the contents of the file read out and save to the structure, when finished the firs

Time:02-12

The first program
# include
# include
# include
Int main (void)
{
The FILE * fp.
Fp=fopen (" access log ", "r +");
if(! Fp) {
Printf (" false ");
}
The else {
Printf (" true ");
}
Char method [255].
Char IP [255];
Char protocol [255].
Char time [255].
Char add [255];
Int port;
Char page [255].
Int the status;
Char exploer_info [255].
Char key;
Char value;

While (port=getc (fp)!=(EOF)
{
Putchar (port);
Struct record
{
Char method [255].
Char IP [255];
Char protocol [255].
Char time [255].
Char add [255];
Char port;
Char page [255].
Char status;
Char exploer_info [255].
Struct prams
{
Char key [255].
Char value [255].
};
Char prams_cnt;
};
The fgets (method, 100, fp);
}
Printf (" % s ", method);
Int fclose (fp) FILE *;
return 0;
}

A second program
# include
# include
# include
Int main (void)
{
The FILE * fp.
Fp=fopen (" access log ", "r +");
if(! Fp) {
Printf (" false ");
}
The else {
Printf (" true ");
}
Char method [255].
Char IP [255];
Char protocol [255].
Char time [255].
Char add [255];
Int port;
Char page [255].
Int the status;
Char exploer_info [255].
Char key;
Char value;

While (port=getc (fp)!=(EOF)
{
Putchar (port);
Struct record
{
Char method [255].
Char IP [255];
Char protocol [255].
Char time [255].
Char add [255];
Char port;
Char page [255].
Char status;
Char exploer_info [255].
Struct prams
{
Char key [255].
Char value [255].
};
Char prams_cnt;
};
The fgets (method, 100, fp);
The fgets (IP, 100, fp);
The fgets (protocol, 100, fp);
The fgets (time, 100, fp);
The fgets (add, 100, fp);
The fgets (port, 100, fp);
The fgets (page, 100, fp);
The fgets (status, 100, fp);
The fgets (exploer_info, 100, fp);
The fgets (key, 100, fp);
The fgets (value, 100, fp);
}
Printf (" % s ", method);
Printf (" % s ", IP);
Printf (" % s ", protocol);
Printf (" % s ", time);
Printf (" % s ", add);
Printf (" % d ", the port);
Printf (" % s ", page);
Printf (" % d ", status);
Printf (" % s ", exploer_info);
Printf (" % s ", key);
Printf (" % s ", value);
Int fclose (fp) FILE *;
return 0;
}
  • Related