Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Match each of these declarators with their description. v int *var[2]; vint (*var)[2]; v int *var(); vint (*var); v int *(*var); v int **var(); A.

image text in transcribedimage text in transcribed

Match each of these declarators with their description. v int *var[2]; vint (*var)[2]; v int *var(); vint (*var); v int *(*var); v int **var(); A. function that returns a pointer to a pointer to an integer B. array of two pointers to integers C. pointer to array of two integers D. pointer to a function that returns a pointer to an integer E. pointer to a function that returns an integer F. function that returns a pointer to an integer QUESTION 10 In the following code, assuming a struct named node is defined. Three instances of node are created, when are these instances destroyed? struct node x; struct node *func() { struct node y; struct node *z = (struct node *) malloc(sizeof(struct node)); return z; } int main() { struct node *w = func(); return 0; A. when func returns B.not officially destroyed, it leaks. The memory will be reclaimed when the program ends. C. when the program ends Please match the following set of elements that might appear in a printf format string with what that element does. %d A. Move the output to the next line v In B. Consider the next parameter to printf as an integer, print that value v % C. Consider the next parameter to printf as a string, print that value %s D. Consider the next parameter to printf as a float, print that value QUESTION 12 The following code is attempting to allocate memory, then fill it with a copy of the string passed into this routine. Unfortunately, there are a number of 'issues with the code. Identify all of the errors in this code. Check all that apply char *copy (char *str) { char *result = malloc(strlen(str); strcpy (result, str); Didn't check to see if the input parameter was NULL Didn't add 1 to the size to leave room for the NULL O Didn't return the final result Didn't cast the return from malloc into the right data type strcpy is the wrong function, use strcat Didn't check to see if malloc returned NULL strlen is the wrong function, use sizeof

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

Expert Oracle Database Architecture

Authors: Thomas Kyte, Darl Kuhn

3rd Edition

1430262990, 9781430262992

More Books

Students also viewed these Databases questions