Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What kind of memory allocation occurs on the blue line of code below? int my_fun() { char *s = (char *) malloc(10); } a. stack

What kind of memory allocation occurs on the blue line of code below?

int my_fun() {

char *s = (char *) malloc(10);

}

a. stack allocation

b. heap allocation

c. both stack and heap allocation

d. neither stack nor heap allocation

Which is the correct way to allocate memory to make a copy of a string foo? (This code shows only the memory allocation, not the copying.)

a. char *s_copy = (char *) malloc(foo);

b. char *s_copy = (char *) malloc(strlen(foo));

c. char *s_copy = (char *) malloc(strlen(foo) + 1);

The line of code below can be fixed by changing one thing? What is it?

int *xp = (int *)malloc(1);

a. The argument passed to malloc()

b. The (int *) in front of malloc

c. The int * at the beginning of the line

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_2

Step: 3

blur-text-image_3

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

Building Database Driven Catalogs

Authors: Sherif Danish

1st Edition

0070153078, 978-0070153073

More Books

Students also viewed these Databases questions

Question

Why is off-balance sheet finance a problem in accounting?

Answered: 1 week ago

Question

=+ (b) Find an example in which A ,, ! A, u( A ,, ) = 00, and A = .

Answered: 1 week ago