Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description: - Change the struct card from the attached file to struct book with the following fields: char array author char array bookName int for

Description:

- Change the struct card from the attached file to struct book with the following fields:

char array author

char array bookName

int for the number of pages

double cost

Modify to reflect the changes from card to book

variables

function prototypes

functions calls

For the array of books use the variable name booklist instead of manycards

#define _CRT_SECURE_NO_WARNINGS #include #include #define SIZE 20

typedef struct{ char face[SIZE]; char suit[SIZE]; int pointV; }card;

//Function Prototypes

// fills the data fields of a card instance //returns the filled card card FillCard();

//fills the data fields of a card instance //by reference using a pointer to a card void FillCardPtr(card *cardptr);

//fills an array of cards void FillCardArray(card arrayC[], int *size);

//displays one card void DisplayCard(card anyCard);

int main() {

//Declare variables card myCard, myCard1, myCard2; card manyCards[SIZE]; int cSize; int i;

//Fill structures with a function myCard = FillCard(); myCard1 = FillCard();

//print using display function printf(" ---------Display myCard "); DisplayCard(myCard); printf(" ---------Display myCard1 "); DisplayCard(myCard1);

//Fill structure using pointers and dispay it FillCardPtr(&myCard2); printf(" ---------Display myCard2 "); DisplayCard(myCard2);

//Fill the array with the function printf(" ---------Fill array manyCards "); FillCardArray(manyCards, &cSize);

//display an array of cards printf(" ---------Display array manyCards "); for(i=0;i

return 0; }

//Function Definitions

// fills the data fields of a card instance //returns the filled card card FillCard() { //Declare local variables card tempC; //prompt and get information printf(" please enter the face of your card: "); scanf("%s", tempC.face); //print to check printf("face: %s ", tempC.face);

//prompt and get information printf(" please enter the suit of your card: "); scanf("%s", tempC.suit); //print to check printf("suit: %s ", tempC.suit);

//prompt and get information printf(" please enter the point value of your card: "); scanf("%d", &tempC.pointV); printf("point value: %d ", tempC.pointV); return tempC; }

//displays one card void DisplayCard(card anyCard) { printf(" face: %s ", anyCard.face); printf("suit: %s ", anyCard.suit); printf("point value: %d ", anyCard.pointV); }

//fills the data fields of a card instance //by reference using a pointer to a card void FillCardPtr(card *cardptr) { //prompt and get information printf(" please enter the face of your card: "); scanf("%s", (*cardptr).face);

//prompt and get information printf(" please enter the suit of your card: "); scanf("%s", cardptr->suit);

//prompt and get information printf(" please enter the point value of your card: "); scanf("%d", &(*cardptr).pointV); }

//fills an array of cards void FillCardArray(card arrayC[], int *size) { int i; //prompt the user printf(" enter the number of cards: "); scanf("%d", size);

//print to check printf("size: %d ", *size);

for (i=0; i < *size; i++) { printf("enter face: "); scanf("%s", arrayC[i].face);

printf("enter suit: "); scanf("%s", arrayC[i].suit);

printf("enter point value: "); scanf("%d", &arrayC[i].pointV); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions