February 2020
Beginner to intermediate
616 pages
15h 16m
English
What if we want to delete an element from an array? The procedure is simply the reverse; in other words, all the elements from the bottom of the array will be copied one place up to replace the element that was deleted.
Let's assume array p has the following five elements (Figure 1.1):

Suppose, we want to delete the third element, in other words, the one at p[2], from this array. To do so, the element at p[3] will be copied to p[2], the element at p[4] will be copied to p[3], and the last element, which here is at p[4], will stay as it is:
The deletefromarray.c program for deleting the array is as follows:
#include<stdio.h> ...
Read now
Unlock full access