English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

4 answers

about the only way is:

char myarray[10] = "abcdefghi";
int count;

say you want to get rid of (or delete) the g in the above array

for (count = 6; count < 8; count++)
___myarray[count] = myarray[count + 1];

now myarray contains "abcdefhi"

just a simple example of how to do it.

2007-04-12 01:32:10 · answer #1 · answered by justme 7 · 0 0

Element that has been created as in an Array can’t be deleted from the memory. It’s not like a train that you remove any block from the train line.

You want to remove it, why? You want to safe memory? If yes, try to use linked list instead of using array. In linked list, it likes an Array but each node or each element is declared when to be used and you can remove it when you don’t want anymore.

Linked List is not a program; it’s one kind of data structure. Array is one kind of data structure and Linked List is the better data structure.

You need some code, see this.

2007-04-11 17:49:31 · answer #2 · answered by nusdunda 3 · 0 1

You can't "delete" an element of an array. What you want is a VECTOR, here's the syntax:
#include
vector myVector();
// from now out you can use it like an array e.g myVector[5]=0
//to "delete" an element use myVector.erase(position);

2007-04-11 08:21:21 · answer #3 · answered by Scooter_MacGyver 3 · 0 1

please can you provide more details, what do you mean by empty slot, does it contain 0 or some junk value. what is the domain of your array actually.

2007-04-11 08:09:39 · answer #4 · answered by junkjaan 1 · 0 1

fedest.com, questions and answers