I am new to programming. I justlearned how to implement arrays both from user input and getting it from a file. I would like to know if anyone could help me in deleting an element from an array in C++? If so I'd greatly appreciate it.
Here is the code I suggest. it will delete your array element. Suppose you found an array element in the position at position i in the array then the code goes like this
That will actually access out of bounds on Array (when j = MaxSize-1). Simply, you can't 'delete' elements from an array, because arrays are fixed-size.
you can't 'delete' elements from an array, that's true but u can replace the content with its succesive elements. virtually 'delete' an array element.
You are write the code I suggest make an assignment out of the scope if we use j<MaxSize; so we need to use j<MaxSize-1;
To "delete" an element from an array you should define a "deleted value" which will differ from all other acceptable values. Otherwise it is difficult to determine whether an element of an array is deleted or not.