70,022
社区成员




int main(void)
{
int max=0;
int temp_max=0;
//only equle 0,1
int compare_result=0;
int loop_compare=0;
int loop_read_search=0;
int leng_of_geweishu_file=204552;
int leng_of_serach_file=210;
char *path_geweishu="result.txt";
char *path_search="search_data.txt";
//int geweishu[leng_of_geweishu_file];
char *search_number=(char *)malloc(sizeof(char)*9);
FILE *search_file;
FILE *result_file;
int *test_number = 56;
printf("Test number is: %d", test_number);
printf("start open file \n");
search_file = fopen(path_search, "r");
result_file = fopen(path_geweishu, "w+");
int temp_result[210];
if((search_file && result_file) == NULL)
{
printf("Can't open file\n");
}
printf("start LOOP to read file \n");
for(loop_read_search=0;loop_read_search<leng_of_serach_file;loop_read_search++)
{
//read_file_search(search_number,search_file);
printf("aready in the loop! \n");
fseek(search_file,(sizeof(int)*4+2),0);
fgets(search_number,16 ,search_file);
//fscanf(search_file,"%d",search_number);
//fscanf(search_file,"%4d",search_number);
temp_result[loop_read_search]=(*search_number);
printf("%d,\n", (*search_number));
fprintf(result_file,"%d \n", temp_result[loop_read_search]);
}
printf("start close file \n");
fclose(search_file);
fclose(result_file);
free(search_number);
}
//每次只返回一行,4个数字
int split_abcde_number(int array[5],char *p_search, FILE *fp_search_temp)
{
int temp_get_number;
int g,s,b,q,w;
//p_search = (char *)malloc(sizeof(char)*400);
fgets(p_search,40 ,fp_search_temp);
temp_get_number=atoi(p_search);
g = temp_get_number%10;
s = temp_get_number/10%10;
b = temp_get_number/100%10;
q = temp_get_number/1000%10;
w = temp_get_number/10000&10;
array[0]=g;
array[1]=s;
array[2]=b;
array[3]=q;
array[4]=w;
printf("Sub loop: %d %d %d %d %d \n",array[4],array[3],array[2],array[1],array[0]);
//free(p_search);
return 1;
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
还麻烦楼上的兄台帮忙看一下,真是要晕死了
原始文件是下面这样:
55237
37183
29135
71101
87747
61105
78918
69044
88571
83811
28308
05650
66871
42625
43931
38815
65422
21901
41622
87522
经过上面那段小程序处理之后,就全部变样了,还麻烦兄台帮忙分析一下
输出如下:
start open file
start LOOP to read file
aready in the loop!
Sub loop: 0 5 2 3 7
0 5 2 3 7
aready in the loop!
Sub loop: 2 7 1 8 3
2 7 1 8 3
aready in the loop!
Sub loop: 2 9 1 3 5
2 9 1 3 5
aready in the loop!
Sub loop: 2 1 1 0 1
2 1 1 0 1
aready in the loop!
Sub loop: 8 7 7 4 7
8 7 7 4 7
aready in the loop!
Sub loop: 2 1 1 0 5
2 1 1 0 5
aready in the loop!
Sub loop: 2 8 9 1 8
2 8 9 1 8
aready in the loop!
Sub loop: 2 9 0 4 4
2 9 0 4 4
aready in the loop!
Sub loop: 8 8 5 7 1
8 8 5 7 1
aready in the loop!
Sub loop: 8 3 8 1 1
8 3 8 1 1
aready in the loop!
Sub loop: 2 8 3 0 8
2 8 3 0 8
aready in the loop!
Sub loop: 0 5 6 5 0
0 5 6 5 0
aready in the loop!
Sub loop: 2 6 8 7 1
2 6 8 7 1
aready in the loop!
Sub loop: 0 2 6 2 5
0 2 6 2 5
aready in the loop!
Sub loop: 0 3 9 3 1
0 3 9 3 1
aready in the loop!
Sub loop: 2 8 8 1 5
2 8 8 1 5
aready in the loop!
Sub loop: 2 5 4 2 2
2 5 4 2 2
aready in the loop!
Sub loop: 2 1 9 0 1
2 1 9 0 1
aready in the loop!
Sub loop: 0 1 6 2 2
0 1 6 2 2
aready in the loop!
Sub loop: 8 7 5 2 2
8 7 5 2 2
aready in the loop!
Sub loop: 2 1 2 3 1
2 1 2 3 1