-So we just started learning about this stuff in class so chances are, this code is horrible... But I need to finish this assignment(the instructions are the comment portion on the top). Some of the problems that I'm having right now is my compiler not liking all of the braces that I have in my BOOK structure initialization...But I can swear it looks just like that our teacher told us to do. Another problem is the pAry. It tells me that 'HEADER' has no member named pAry. But I don't know how to fix this because I put pAry in HEADER already.Code:/* Complex Structures 6 Points Define pHead, a pointer to a structure called HEADER. This structure contains two fields: a counter (type int) and a pointer to an array of structures, called pAry. The base type of the pAry array is another structure called BOOK. This BOOK structure contains three fields: title (a dynamically allocated string), author (30 characters), and date of type DATE (a structure with three integers: month, day, and year). Requirements: 1. Type Definitions 2. In main(), define an array of 5 books and initialize it. 3. Write printBook(), a function that prints a book: void printBook( const BOOK *p ); 4. Write a function that prints the array of books using the printBook() function in a loop. 5. Code a printf statement to print - the title, - the first letter of the author's name, and - the year of the third book in the array. Save the output as a comment then upload the program. Written by:Anastasia Glyantseva Date: 6/5/2012 // ====================================================== */ #include <stdio.h> #include <string.h> #define MAX_TITLE 100 void printBook( const BOOK *p); typedef struct { char title[MAX_TITLE]; char author[30]; typedef struct { int month; int day; int year; }DATE; } BOOK; typedef struct { int counter = 0; char *pAry = *BOOK; }HEADER; int main( void ) { // Local definitions BOOK list[5]= { {"Title1", "Author1", {1, 26, 2001}}, {"Title2", "Author2", {2, 27, 2002}}, {"Title3", "Author3", {3, 28, 2003}}, {"Title4", "Author4", {4, 29, 2004}}, {"Title5", "Author5", {5, 30, 2005}}, }; // Statements HEADER head = {5, list}; HEADER *pHead = &head; pHead -> pAry[2].title; *(pHead -> pAry[2].author); pHead->pAry[2].date.year; return ; } void printBook( const BOOK *p) { }
Anyway, thank you for your time and sorry if this code looks really stupid.