Question

a 14. Suppose a pointer to a structure, bookPte, is defined. This structure also contains member, price that is a pointer to a double. Provide the equivalent to bookPtr price?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

equivalent to *bookptr->price is (*bookptr).price)

//below demonstrated the same

#include<stdio.h>

//book struct is defined

typedef struct book

{

double price;

};

int main()

{

//created book structure

struct book *bookptr=(struct book*)malloc(sizeof(struct book)*1);

//printing the data

printf("%d\n",bookptr->price);

//using another way to print from struct pointer

printf("%d",(*bookptr).price);

return 0;

}

//compiling and running the code (some garbage value will print as not initialized the price value)

printed by *bookptr->price 7428816 printed by (bookptr).price) 7428816 Process exited after 0.2549 seconds with return value

Please do let me know if u have any doubts..

Add a comment
Know the answer?
Add Answer to:
Suppose a pointer to a structure, bookPtr is defined. This structure also contains a member, price...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ***Using C++ and also please label "a" and "c" accordingly. Thank you!!**** a) Write the member...

    ***Using C++ and also please label "a" and "c" accordingly. Thank you!!**** a) Write the member function void deleteNode() that will delete the first node from the linked list. b) Modify the LList to create a data member Node *cur that points to the current node. Write the following member functions: • void forward() that moves the cur pointer to the next node. • void backward() that moves the cur pointer to the previous node. • void delete() that removes...

  • Help fast :Assume a variable called orange exists of type Fruit pointer. The Fruit structure is...

    Help fast :Assume a variable called orange exists of type Fruit pointer. The Fruit structure is defined below. For the variable orange, write a statement that assigns a member variable named hasSeeds to 1 typedef struct Fruit struct f a. &(orange.hasSeeds) 1; b. orange.("hasSeeds) 1 c. orange->hasSeeds 1; d. orange.hasSeeds 1; // menber variables Fruit; Q8: When the malloc function is called, the malloc function returns a(n) a. address on the heap b. address on the stack c. address on...

  • (C++)Declare a pointer variable bookPtr and initialize it with the address of myBook. Use the structure...

    (C++)Declare a pointer variable bookPtr and initialize it with the address of myBook. Use the structure pointer operator (->) to change the price of myBook to $100. Thank you :)

  • Suppose the base class and the derived class each have a member function with the same...

    Suppose the base class and the derived class each have a member function with the same signature. When you have a pointer to a base class object and call a function member through the pointer, discuss what determines which function is actually called—the base class member function or the derived-class function.

  • 3. Suppose you have a linked list structure and a node structure defined as follows: template...

    3. Suppose you have a linked list structure and a node structure defined as follows: template <class T> class llist { lnode<T> *header; llist() { header = new lnode<T>(T()); header->prev = header; header->next = header; } void eraseAll(const T& target); }; template <class T> struct lnode { T val; lnode<T>* next; lnode<T>* prev; lnode(const T& x, lnode<T>* y=NULL, lnode<T>* z=NULL) : val(x), next(y), prev(z) {} }; Write the llist member function eraseAll, which takes a value target and erases all...

  • Using C, practice more with structure. Example make Car struct and give member: char mak[15]; double...

    Using C, practice more with structure. Example make Car struct and give member: char mak[15]; double price; char vinNum[15]; // Note make sure you have a member that uniquely identify struct. example Student ID

  • C++ program, item.cpp implementation. Implementation: You are supposed to write three classes, called Item, Node and In...

    C++ program, item.cpp implementation. Implementation: You are supposed to write three classes, called Item, Node and Inventory respectively Item is a plain data class with item id, name, price and quantity information accompanied by getters and setters Node is a plain linked list node class with Item pointer and next pointer (with getters/setters) Inventory is an inventory database class that provides basic linked list operations, delete load from file / formatted print functionalities. The majority of implementation will be done...

  • Suppose an industry is composed of 50 price-taking firms, each one possessing the cost structure given...

    Suppose an industry is composed of 50 price-taking firms, each one possessing the cost structure given below: Quantity 0 1 2 3 4 5 6 Total Cost 100 150 180 240 320 420 550            Also assume the market demand curve contains the following points: Quantity Demanded 250 200 150 100 50 0 Price 0 30 60 80 100 130              What is the equilibrium price in this market? Group of answer choices a P = 60 b P =...

  • Question 9. Let (A-) be a binary structure. When the book defined identity, it meant 2...

    Question 9. Let (A-) be a binary structure. When the book defined identity, it meant 2 sided identity, but it is also possible to talk about one sided (right and left) identities. Come up with a reasonable definition of the terms: left identity (denoted by ez) and right identity denoted by eR). (a) Is it true that, if a left (respectively, right) identity exists, then it is unique? If it is true, prove it; if it is false, provide a...

  • Please provide solution, also 1. (Capital structure) Suppose the weighted average cost of capital of Gadget...

    Please provide solution, also 1. (Capital structure) Suppose the weighted average cost of capital of Gadget Company is 10%. If Gadget has a capital structure of 50% debt and 50% equity, a before-tax cost of debt of 5%, and a marginal tax rate of 20%, then its cost of equity capital is closest to: (a) 12% (b) 14% (c) 16%

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT