I'm confused by pointers to structs in C and part of my problem is that the examples I find are seemingly wrong.
In this example code I found here, I still get the dreaded error:
warning: assignment from incompatible pointer type
#include <stdio.h>
struct Book
{
char name[10];
int price;
}
int main()
{
struct Book a; //Single structure variable
struct Book* ptr; //Pointer of Structure type
ptr = &a;
struct Book b[10]; //Array of structure variables
struct Book* p; //Pointer of Structure type
p = &b;
return 0;
}
Does anybody have a working example for me to learn from?