1. Engineering
  2. Computer Science
  3. c program these functions create and access an array of...

Question: c program these functions create and access an array of...

Question details

C PROGRAM

These functions create and access an array of strings using malloc. I need 4 functions that have this functionality, there is no other question. i dont need a main() but it can be used for testing the function. Please use comments to explain important parts

char **createStringArray (int num)

This function dynamically allocates an array of pointers that will point to the strings. It takes one parameter which is the size of the array of pointers. (The amount of pointers it you will hold)

Void setArrayString (char **array, int index, char *string)

this function stores a string in the array. The string passed into the function must have memory already allocated for it and must already be copied Into that space. The parameters are:

-the array of strings allocated using createStringArray()

-The location in the array where the string will be stored

-the string to store in the array

Char *getStringArray (char **array, int index)

this function return a string from the array. Parameters are:

-the array of string allocated using createStringArray()

-the location in the array where the string is stored

Void freeStringArray (char **array, int num)

this function frees the memory allocated using createStringArray() and any strings stored in the array. The parameters are

-the array of strings allocated using createStringArray()

-the size of the array

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution