Question: ALL ANSERS RELATE TO C PROGRAMS WRITTEN IN LINUX OS Which of the following are true about dynamic memory and structs? Select one or more:
ALL ANSERS RELATE TO C PROGRAMS WRITTEN IN LINUX OS


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); b. For a dynamically created 2D array, we can call free() on its previously malloc()'d pointers in any order. c. 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. d. 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. 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. 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); b. 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. c. Pointers are special variables that store a reference to another variable in the form of a memory address. d. 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; e. 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
