感谢您的回答,但在此之前我的代码可以从文件中读取并打印出该区域的值!我的问题是如何在“FOR LOOP”之外使用这些值。因为我不想在需要值的任何时候继续读取文件,假设数组 data[][] 包含文件的所有内容.......是否可以在循环外调用数组及其打印出所有的文件内容?
//file
S (20,22)(129,37)
S (10,18)(40,200)
S (10,20)(39,15)
S (30,400)(750,200)
S (160,70)(240,20)
S (40,40)(10,39)
S (6,65)(94,2)
S (404,40)(110,39)
S (86,61)(50,19)
//part of code.........
int count=1;
for (i=0; i <= count; i++)
{
while(fscanf(file, "S (%d,%d)(%d,%d)\n", &a, &b, &c, &d) !=EOF)
{
data[i][0] =a;
data[i][1] =b;
data[i][2] =c;
data[i][3] =d;
printf("%d,%d,%d,%d\n",data[i][0], data[i][1], data[i][2], data[i][3]);
XDrawLine(display_ptr, win, gc_grey,a, b, c, d);
count++;
}
// want to call the array data[i][j] here outside the iteration above..
int j1=0;
for (i=0; i <= 19, j1<=3; i++) {
printf("%d\n",data[i][0]);
}