Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For each of the following descriptions, give a declaration for a variable named foo , and initialize it by calling malloc() or calloc() to point

For each of the following descriptions, give a declaration for a variable named foo, and initialize it by calling malloc() or calloc() to point to space for the described type. Write portable code, i.e., code that does not assume particular sizes for C types (except char). For example, if the description is an array big enough to hold a null-terminated string of up to 31 characters, you would write:

char *foo = malloc(32*sizeof(char)); or, since the language guarantees that sizeof(char) is guaranteed to be 1 on all platforms, char *foo = malloc(32);

a. An array of n ints. b. An array of 10 unsigned longs. c. A struct strstr. d. An array of count C-style strings (i.e., pointers to char).

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

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions