my code is here
Code:
void putbook(libr *lib, int cnt)
{
int i;
long unsigned int sal;
printf("You will be adding information for %d books.\n", cnt);
for (i=0; i<cnt; i++)
{
printf("\nFor book #%d Enter the access No: ", (i+1));
scanf("%d[^\n]",&(*lib).accessNum);
printf("Enter the author's name(lastname, firstname):");
fgets((*lib).name, 100, stdin);
printf("%s", (*lib).name);
printf("Enter the books information:\nTitle:\n");
fgets((*lib).book.title, 100, stdin);
printf("%s", (*lib).book.title);
printf("Price\n");
scanf("%f", &(*lib).book.price);
printf("Year\n");
scanf("%d", &(*lib).book.year);
printf("Enter the books status (Available, Not_Available, Reference_Only, Online): ");
scanf("%d", &(*lib).Status);
printf("\n");
lib++;
}
}
my first fgets is skipped, i think because i'm using scanf before gets and it leaves a \n behind in the keyboard buffer, i've tried all types of buffer clearing, any suggestions on how I can get my fgets to stop skipping??
thank you.