I have defined 2 structs:
typedef struct Book
{
char* name;
char ID[11];
}Book;
and
typedef struct Library
{
char name[MAX];
int num_books;
Book *books;
}Library;
my question is in this function:
void input_book(Book* B, FILE* in)
{
char s[MAX+1];
if (fscanf(in, "%s %s", (B->ID), s) != 0);
B->name = (char*)malloc((strlen(s) * sizeof(char)) + 1);
if (B->name == NULL)
Get_Lost("Couldn't open file. Exiting..");
else
strcpy(B->name, s);
}
The part where I use fscanf, should there be an & before (B->ID)? It works both with & and without, I'd love an explanation as to why it should/shouldn't. I use Visual Studio 2019 and this code is in C language only
I'm quite new to coding so I hope I've provided enough information for you to work with, thanks!