I have an array of structures which need filling by the user. I have tried doing this by declaring a pointer to the structure array, and then using the for loop to run the pointer through the array. Finally the structure will be saved as a bin to disk for later retrieval. Can someone please tell me what Im doing wrong as this just keeps skipping the second prod. Is this actually saving data to the structure? Am I going about this the wrong way all together. Ive been going through my "c for linux programming" book but cant find what to do? Any suggestions please. Here is the code.(Ive only posted the relevant parts, and the for loop stops at 37, just an example)
Code:
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<windows.h>
#include<string.h>
/*structure to hold all info, final program will contain structures of main meal, snacks*/
/*and also deserts, using this structure*/
struct database {
char prod[60];
float cal;
float carb;
float prot;
float fat;
};
/*function prototypes*/
int full_screen(void);
void main_menu(void);
void about_opt(void);
void help_opt(void);
FILE *fp;
struct database *point1;
int count;
int main()
{
full_screen(); /*Puts the dos console into full screen when program is executed*/
struct database mainm[100];
point1 =&mainm[0];
for ( count = 0; count < 37; count ++ )
{
printf("Enter the product:");
fgets(point1->prod, 60, stdin);
printf("\nEnter cal:");
scanf("%f", & point1->cal);
printf("\nEnter carb:");
scanf("%f", &point1->carb);
printf("\nEnter protein:");
scanf("%f", &point1->prot);
printf("Enter fat:");
scanf("%f", &point1->fat);
}