我有客户数据,例如客户编号、位置坐标等。文本文件中有 25 个客户。
这是我的代码。当我打印它时,这给了我一个零输出。
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#define customerCount 25
struct customerData
{
int customerNo;
double xCoordinate;
double yCoordinate;
double demand;
double readyTime;
double dueTime;
double serviceTime;
};
int main()
{
int i;
struct customerData allSubscriber[customerCount];
FILE *dosya;
dosya = fopen("c:\\solomon_c101.txt", "r");
for(i=1; i<=customerCount; i++)
{
fscanf(dosya, "%d %f %f %f %f %f %f", &allSubscriber[i].customerNo, &allSubscriber[i].xCoordinate, &allSubscriber[i].yCoordinate, &allSubscriber[i].demand, &allSubscriber[i].readyTime, &allSubscriber[i].dueTime, &allSubscriber[i].serviceTime);
}
fclose(dosya);
for(i=1; i<=customerCount; i++)
{
printf("%f\n", &allSubscriber[i].xCoordinate);
}
getch();
return 0;
}