Complaint: Disappointed

Pages: 12
thanks
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
int main()
{

printf("\n\nEnter unit:\t");
scanf("%d", &Inventory[a].stock);
		 
 while(Inventory[a].stock!=0)
{
printf("\nMovie Title:\t");
fflush(stdin);
gets(Inventory[a].name);
  fflush(stdin);
 printf("\nCost Price:\t");
 scanf("%f", &Inventory[a].costpr);
 a=a++; 
 printf("\n\nEnter unit:\t");
 scanf("%d", &Inventory[a].stock);
         		   	
} //endwhile

 
 while(Inventory[a].stock!=0)
 {
 gets(Inventory[a].name);
  printf("\nCost Price:%f\t", &Inventory[a].costpr);
  printf("\n\nEnter unit: %d\t", &Inventory[a].stock);
         		
 a=a++; 
         	
  }
return 0;
}


ive tried the while loop like that and it does work. it will loop continuously with the last data inputted.
Last edited on
> while(Inventory[a].stock!=0)
¿did you initialise your variables correctly?
¿does that condition holds so you can read the data?

you don't seem to reset `a' before trying to do the output.


> fflush(stdin);
The manual specify the behaviour «For input streams associated with seekable files (e.g., disk files, but not pipes or terminals)»
I have no idea what's that supposed to do in your case.


> a=a++;
that's undefined behaviour, don't use such constructions.
You may simply do ++a;
Last edited on
Topic archived. No new replies allowed.
Pages: 12