Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this function
void insert_book(void)
is meant to read book information into the 6th element of global array book_array sth goes wrong..when I test it with this simple main call ...the console outputs 0 and doesn't take any input

What I have tried:

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <stdbool.h>
typedef struct
{
    int day;
    int month;
    int year;
} dateStruct;
typedef struct
{
    char title[10];//we need to handle longer titles
    char author[10];//same
    char publisher[10];//same
    char ISBN[10];
    dateStruct date;
    int copies;
    int current;
} book;
book book_array[50];
int i=5;
void insert_book(void)
{
   book inserted;
   gets(inserted.title);
   gets(inserted.author);
   gets(inserted.publisher);
   gets(inserted.ISBN);
   scanf("%d%d",&(inserted.copies),&(inserted.current));
   scanf("%d%d%d",&(inserted.date.day),&(inserted.date.month),&(inserted.date.year));
   book_array[i]=inserted;
   i++;
    return ;
}
int main()
    {
       insert_book;

       printf("%d",book_array[5].date.day);


        return 0;
    }
Posted
Updated 29-Nov-17 22:28pm
v2

1 solution

C++
insert_book;

is not a correct function call, it should be
C++
insert_book();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900