This is my function:
Int main (void)
{
Int I=0;
Char pbufs [256]="the 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]."
The FILE * fp=NULL;
Int length=0;
Int num=0;
Char buf [256]={0};
The FILE * fp_tmp=NULL;
Fp=fopen ("//the size * * *. TXT ", "wr +");//this is the path to the file;
Fp_tmp=fp;
While (I & lt; 14)
{
i++;
If (fp==NULL)
{
Printf (" open file error \ r \ n ");
return;
}
The fgets (buf, 300, fp_tmp);
Printf (" % s (% d) : in buf: % s \ n ", __FUNCTION__ and __LINE__, buf);
Fprintf (fp, "% s \ r \ n", pbufs);
}
fclose(fp);
}
Results:
* * * * * * * * * * : - $./for_test
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
In the main [28] : buf:
This is performed after the size. TXT file contents:
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
The 1970-01-01 02:24:51 [Error] WEB ALARM: test_str: [Log utility testing... , test_val: [12, 0 xc], BBBL abcd [123], [234]
Wonder why the fgets () to read out the contents of the file;
Please comment:
CodePudding user response:
Wrong path, the path of the slash is against, also for three star,CodePudding user response: