Question
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
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