G
Guest
I recently find that if I use scanf() in a for loop,the function
doesnot work as I
wish.
for example:
struct person{
int price;
long milk;
struct person *next;
};
struct person *head;
struct person *pre;
struct person *now;
struct person *come;
for(i=1;i<=M;i++){
come=new struct person;
scanf("%d %ld ",&come->price,&come->milk);
ey);
…………
}
In the first time I have to input four numbers ,but the scanf() only
read the first two,and in the sencond time I also input two number,but
the scanf() read the last two of the first time?
Why is it?
~~
sorry ,My English is poor.
doesnot work as I
wish.
for example:
struct person{
int price;
long milk;
struct person *next;
};
struct person *head;
struct person *pre;
struct person *now;
struct person *come;
for(i=1;i<=M;i++){
come=new struct person;
scanf("%d %ld ",&come->price,&come->milk);
ey);
…………
}
In the first time I have to input four numbers ,but the scanf() only
read the first two,and in the sencond time I also input two number,but
the scanf() read the last two of the first time?
Why is it?
~~
sorry ,My English is poor.