fscanf 没有存储任何结果
nothing is stored as the result of fscanf
#define TERMMAX 100
typedef struct{
int coef;
int expon;
} poly;
poly term[TERMMAX];
int avail = 0;
#define TERMMAX 100
enter code here
int main()
{
int i;
FILE *fp = fopen("a.txt", "r");
while(fscanf(fp, "%d\t%d", &term[avail].coef, &term[avail].expon) != EOF)
avail++;
上面的 fscanf 部分工作得很好,但下面的 fscanf 却不行。
while(fscanf(fp, "%d\t%d", &term[avail].coef, &term[avail++].expon) != EOF)
;
term[].expon 中没有存储任何内容。为什么?
IIRC,标准未指定函数参数的计算顺序。函数参数的任何副作用都不确定地排序。
#define TERMMAX 100
typedef struct{
int coef;
int expon;
} poly;
poly term[TERMMAX];
int avail = 0;
#define TERMMAX 100
enter code here
int main()
{
int i;
FILE *fp = fopen("a.txt", "r");
while(fscanf(fp, "%d\t%d", &term[avail].coef, &term[avail].expon) != EOF)
avail++;
上面的 fscanf 部分工作得很好,但下面的 fscanf 却不行。
while(fscanf(fp, "%d\t%d", &term[avail].coef, &term[avail++].expon) != EOF)
;
term[].expon 中没有存储任何内容。为什么?
IIRC,标准未指定函数参数的计算顺序。函数参数的任何副作用都不确定地排序。