Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Which of the following are true about dynamic memory and structs? Select one or more: a. To dynamically request sufficient memory for a string containing
Which of the following are true about dynamic memory and structs? Select one or more: a. To dynamically request sufficient memory for a string containing the message "Hello FIT2100", we can use the following line of code: char *message (char *) malloc(sizeof(char) * 13); ob. A struct is essentially a group of several variables, functions and/or methods of potentially varying data types that are all under a same name. = c. For a program that allows the user to enter a string where the length of this string varies based on the user's previous inputs, dynamic memory should be used. d. For a dynamically created 2D array, we can call free() on its previously malloc()'d pointers in any order. e. Members of a struct can either be accessed via dot notation, or the arrow operator if accessing them via pointers. Which of the following are true about pointers and strings? Select one or more: a. The following code allows us to validly obtain the memory address of an integer my_int, and store it in an integer pointer the_address: int my_int = 0; int* the_address &my_int; b. To obtain the fifth character in a char array variable called my_string, we can use the following line of code: char fifth_char = *(my_string + 5); = c. Pointers are special variables that store a reference to another variable in the form of a memory address. d. A pointer to a variable can be passed to a function to allow us to retain the changes made by the function to the actual value of that variable, even after returning from said function. e. The process of obtaining the value stored at a memory address pointed to by a pointer is called referencing and can be done with the * operator
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started