Yesterday I created a thread called "File Handling Problems!!"..... today within the first half an hour I have moved forward a bit (which is a relief)..... but I still have a problem.....
1.#include <stdio.h>
2.#include <string.h>
3.
4.int main()
5.{
6. int week = 0;
7. int units = 0;
8. int price = 0;
9. char name[30];
10. int count = 13;
11. int i = 0;
12. //int total = 0;
13. int total_Sale[13];
14.
15. struct sale
16. {
17. int week;
18. int units;
19. int price;
20. char name[30];
21. }weekly_Sale[13];
22.
23. for (i = 0; i < 13; i++)
24. {
25. scanf("%i %i %i %s", &weekly_Sale[i].week,
26. &weekly_Sale[i].units, &weekly_Sale[i].price,
27. weekly_Sale[i].name);
28. //i++;
29.
30. }
31.
32. //while (weekly_Sale[i].week < 13);
33.
34. for (i = 0; i < count; i++)
35. {
36. printf("%i %i %i %s ", weekly_Sale[i].week,
37. weekly_Sale[i].units, weekly_Sale[i].price, weekly_Sale[i].name);
38. }
39. return 0;
40. }
.....the problem is where the for loop is, because it should stop the program once the number "13" has been entered and output all the values that have been stored in the struct but it doesn't stop on 13, and it doesnt stop on anything above either (e.g. 14)..... can someone please check it out and let me know what they might think the problem could be?
thanks in advance!