Question
The language is C, Write a program with the following functions int* allocate(int n) - this function will allocate a block of memory to store
The language is C, Write a program with the following functions
int* allocate(int n) - this function will allocate a block of memory to store n integers and will return a pointer to that block of memory. The allocation should initialize all of the allocated integers to zero and print the values to confirm.
void set(int *b, int value, int index) - this function will take in a pointer to the block of memory and store the integer "value" at the specified index.
int get(int *b, int index) - this function will return the integer stored at the specified index.
Write a program that supplies a menu that will allow you to call allocate(), set(), get(), and quit. You should be able to use this menu to store multiple pieces of data in the memory block and recall them. Make sure that when you quit, you also free up your memory.
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