我在尝试从 .txt 文件中读取时遇到问题,文件示例:“12345 qwe>rty 12345 q=wert qe/ry”尝试读取超过 50 000 条类似的行,将它们与另一个进行比较(也从 doc. ) 数组,但程序每次都会刹车......代码 supote 比较 2 个数组,如果它们匹配,则在新文档中打印它们。希望我解释清楚...`
#include <stdio.h>
#define max 57000
main()
{
int i, j, n;
char (*ime[200])[max], (*grad[200])[max], (*adresa[200])[max];
int rb[max], rbk[max], posta[max], check[max];
FILE *svi = fopen("C:\\Users\\Fujitsu\\Desktop\\001.txt", "r");
FILE *kupci = fopen("C:\\Users\\Fujitsu\\Desktop\\002txt", "r");
FILE *izlaz = fopen("C:\\Users\\Fujitsu\\Desktop\\003.txt", "w");
// reading from 001.txt//
//
printf("1"); //some kind of check point
for (i = 2; i < 56300; i++)
{
fscanf(svi, "%d%s%d%s%s", &rb[i], &ime[i], &posta[i], &grad[i], &adresa[i]);
check[i] = 0;
fscanf(kupci, "%d", &n);
rbk[n] = 0;
}
//matching 001 i 002//
printf("2");
for (i = 2; i < 56300; i++)
{
if (check[i] == rbk[i])
{
check[i] = 1;
}
//stampanje u novu datoteku 003 //
if (check[i] == 0)
{
fprintf(izlaz, "%szt%d\t%s\t%s\t\n", ime[i], posta[i], grad[i],
adresa[i]);
;
}
}
fclose(svi);
fclose(kupci);
fclose(izlaz);
printf("done");
getch();
}
先感谢您