Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you. However, I will give you some pointers. Fi...
Answer
#4: Post edited
- Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you.
- However, I will give you some *pointers*.
- First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.)
- Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data (and possibly other memory as well) such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title?
- Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically?
- Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have? Again, what does that do to the memory space occupied by the `aBook` variable instance specifically?
Here's a bit of a hint: the answers to the above will also help you find the next book in an arbitrarily-sized library.
- Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you.
- However, I will give you some *pointers*.
- First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.)
- Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data (and possibly other memory as well) such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title?
- Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically?
- Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have? Again, what does that do to the memory space occupied by the `aBook` variable instance specifically?
- Here's a bit of a hint and teaser alike: the answers to the above will also help you find the next book in an arbitrarily-sized library.
#3: Post edited
- Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you.
- However, I will give you some *pointers*.
- First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.)
- Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data (and possibly other memory as well) such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title?
- Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically?
Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have?- Here's a bit of a hint: the answers to the above will also help you find the next book in an arbitrarily-sized library.
- Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you.
- However, I will give you some *pointers*.
- First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.)
- Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data (and possibly other memory as well) such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title?
- Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically?
- Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have? Again, what does that do to the memory space occupied by the `aBook` variable instance specifically?
- Here's a bit of a hint: the answers to the above will also help you find the next book in an arbitrarily-sized library.
#2: Post edited
- Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you.
- However, I will give you some *pointers*.
- First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.)
Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title?- Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically?
- Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have?
- Here's a bit of a hint: the answers to the above will also help you find the next book in an arbitrarily-sized library.
- Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you.
- However, I will give you some *pointers*.
- First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.)
- Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data (and possibly other memory as well) such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title?
- Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically?
- Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have?
- Here's a bit of a hint: the answers to the above will also help you find the next book in an arbitrarily-sized library.
#1: Initial revision
Since this is pretty clearly a homework exercise, and the point of those is for you to learn, I'm going to be evil and not spoon-feed the answer to you. However, I will give you some *pointers*. First, consider what the `struct book` *actually contains*. What is the actual variable type of its members? (Which in your example are all the same, but of course could be different if you were to also, say, store the year of publication or the number of pages in or the physical weight of each respective book.) What does that variable type mean for the actual *data* at the specific memory location occupied by an actual *instance* of that struct, such as your `aBook` variable? Basically, if you were to look at the actual memory occupied by `aBook` immediately before the assignments to members of it (which begin at the line that has your comment "how should I write in the double quotes?"), what would you see and how would that relate to what the computer is doing under the hood when running your program? (For simplicity, assume that your program is the only thing that is running on the computer; don't consider things like multitasking, swapping memory to disk, and so on.) Second, considering what you see at the memory occupied by `aBook`, what change would need to be made to that in-memory data such that you can use the members of `aBook` to hold a reasonable amount of arbitrary data, such as a book title? Third, in C, how do you make such a change? What does that do to the memory space occupied by the `aBook` variable instance specifically? Fourth, having made that change, how do you store a value such that it can later be read back, using only what's accessible through the `aBook` variable that you do have? Here's a bit of a hint: the answers to the above will also help you find the next book in an arbitrarily-sized library.