I have the following code ...
Code:
#include <stdio.h>
int main (void)
{
struct book
{
char name[25];
char author [25];
int callno;
};
struct book b1 = { "Moubidick", "Ansari,Shahin", 101};
display (b1);
}
display (struct book b)
{
printf ("\n Here is the book information %s %s %d", b.name, b.author, b.callno);
}
~
Code:
And I get the following warnings:
struct3.c:14:17: warning: 'struct book' declared inside parameter list
display (struct book b)
^
struct3.c:14:17: warning: its scope is only this definition or declaration, which is probably not what you want
struct3.c:14:22: error: parameter 1 ('b') has incomplete type
display (struct book b)
^
I looked around online, and I believe the warnings are for not declaring the variable b earlier in the main. Is that right?
I like to know if what I am doing is the best way to go about passing a structure to a function. It is not my code; I am following a text and it may be that the author is trying to teach something, which he'll build on later.