Hey, im new to C and i'd like to know how I can display the information stored in an array.
How can the code work so that if only 3 slots (for example) in the array are stored with information, the info stored in a[4], and a[5] will not print.
I'm aware of the concepts of for loops, however I cant seem to figure out how to limit how many messages are displayed depending on how many slots in the array contain user stored information (as mentioned above).
Code:
printf(" %d-%d-%d %lf\n", a[1].day, a[1].month, a[1].year, a[1].GPA);
printf(" %d-%d-%d %lf\n", a[2].day, a[2].month, a[2].year, a[2].GPA);
printf(" %d-%d-%d %lf\n", a[3].day, a[3].month, a[3].year, a[3].GPA);
printf(" %d-%d-%d %lf\n", a[4].day, a[4].month, a[4].year, a[4].GPA);
printf(" %d-%d-%d %lf\n", a[5].day, a[5].month, a[5].year, a[5].GPA);
Thanks