At the 3 times in the loop, something happened, which is memorization error.
execution: 3 times in loop:
...
a_compare ends
i: 222 loop ends. |ni| next |105| end|0| count 2 level_002
i: 223 loop starts.
a_compare|cn||
| 003
case sep=2
a_compare ends
i: 223 loop ends. |cn゚| next |110| end|0| count 3 level_002
i 0 |99| |cn゚|
i 1 |110| |cn゚|
i 2 |-33| |cn゚|
---
execution: 2 times in loop:
...
a_compare ends
i: 221 loop ends. |i| next |0| end|0| count 1 level_002
i: 222 loop starts.
a_compare|ni||
| 003
case sep=1
a_compare ends
i: 222 loop ends. |ni| next |105| end|0| count 2 level_002
i 0 |110| |ni|
i 1 |105| |ni|
source code:
----
main.cpp Sun Sep 27 16:13:36 2020
35 :// From Head :
36 ://
37 :// int index :
38 :// int file_end :
39 :// FILE* fp :
40 :int found_level_001 (int index, int file_end, FILE *fp ) {
41 : char b_dummy[256];
42 : int i, j ;
43 : FILE *tfp;
44 :// char keyword[2][5] = { "#", "/*" };
45 : char* keyword[2] = { "#", "/*" };
46 :
47 : tfp = fp;
48 : for ( j=0; j<256; j++ ) {
49 : b_dummy[j] = '\0';
50 : }
51 :
52 : for ( i =index; i<file_end; i++ ) {
53 : printf("i: %d loop starts.\r\n", i );
54 :
55 : for ( j=254; j>=0; j-- ) {
56 : b_dummy[ j + 1 ] = b_dummy[ j ];
57 : }
58 :
59 : fread ( dummy, 1, 1, fp);
60 : b_dummy[ 0 ] = dummy[0];
61 :
62 :// if ( a_compare( (char*)b_dummy, (char*)"\r\n" ) == 1 ) {
63 : if ( a_compare( (char*)b_dummy, (char*)keyword[0] ) == 1 ) {
64 : printf("We found Sharp |%s| index %d i %d tfp %d fp %d\r\n", b_dummy, index, i, tfp, fp);
65 : found_level_002 ( i + 1, file_end, fp );
66 : exit( -1 );
67 : }
68 :
69 : printf("i: %d loop ends.\r\n", i );
70 : }
71 :}
72 :
73 :// From Head :
74 ://
75 :// int index :
76 :// int file_end :
77 :// FILE* fp :
78 :int found_level_002 (int index, int file_end, FILE *fp ) {
79 : char b_dummy[256];
80 : int i, j ;
81 : FILE *tfp;
82 :// char keyword[2][5] = { "#", "/*" };
83 : char* keyword[2] = { "\r\n", "/*" };
84 : int count = 0;
85 :
86 : tfp = fp;
87 : for ( j=0; j<256; j++ ) {
88 : b_dummy[j] = '\0';
89 : }
90 :
91 : for ( i =index; i=0; j-- ) {
95 : b_dummy[ j + 1 ] = b_dummy[ j ];
96 : }
97 :
98 : fread ( dummy, 1, 1, fp);
99 : b_dummy[ 0 ] = (char) dummy[0];
100 :
101 : // put_tokene is still useful if you don't like b_dummy.
102 : if ( a_compare( (char*)b_dummy, (char*)keyword[0] ) == 1 ) {
103 : printf("We found Enter |%s| index %d i %d tfp %d fp %d count %d\r\n", b_dummy, index, i, tfp, fp, count);
104 : exit( -1 );
105 : }
106 :
107 : count++;
108 : printf("i: %d loop ends. |%s| next |%d| end|%d| count %d level_002\r\n", i, b_dummy, b_dummy[1], b_dummy[count], count );
109 : }
110 :
111 : for ( i =0; i<count; i++ ) {
112 : printf("i %d |%d| |%s| \r\n", i, b_dummy[i], b_dummy );
113 : }
114 :}
115 :
----