473,563 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deleting Array Element

How can I delete one or more elements of an array.
let a[]={1,2,3,4,5} Now i want to send the third element '3' to an
array b[10] and remove the element from a.

How can I do it?

Jun 13 '07 #1
13 13869
Umesh wrote On 06/13/07 10:46,:
How can I delete one or more elements of an array.
let a[]={1,2,3,4,5} Now i want to send the third element '3' to an
array b[10] and remove the element from a.

How can I do it?
You cannot.

The array has five elements, a[0] through a[4], and
there is no way to change that. You can, at best, change
the values that are stored in those elements; for example,
you might change them to { 1, 2, 4, 5, -1 }. But you
cannot make the elements "go away."

--
Er*********@sun .com
Jun 13 '07 #2
How can I remove duplicate entries from an array?

Jun 13 '07 #3
Umesh said:
How can I remove duplicate entries from an array?
By replacing them with unique entries.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 13 '07 #4
Umesh wrote On 06/13/07 11:35,:
How can I remove duplicate entries from an array?
The message to which your query is a response
explained why you cannot remove elements from an
array. You must have seen the message -- you posted
a reply to it -- but did you read it?

--
Er*********@sun .com
Jun 13 '07 #5
Umesh wrote:
How can I remove duplicate entries from an array?
Perhaps an array is the wrong choice for your data and algorithm? You
might be thinking of a linked-list, which can be built on top of an
array, if you like.
--
clvrmnky <mailto:sp***** *@clevermonkey. org>

Direct replies will be blacklisted. Replace "spamtrap" with my name to
contact me directly.
Jun 13 '07 #6
On 13 Jun, 16:56, Eric Sosman <Eric.Sos...@su n.comwrote:
Umesh wrote On 06/13/07 11:35,:
How can I remove duplicate entries from an array?

The message to which your query is a response
explained why you cannot remove elements from an
array. You must have seen the message -- you posted
a reply to it -- but did you read it?
Yours wasn't a response which fixed his perceived problem, so he
ignored it and raised a new issue. What's surprising there?

Jun 13 '07 #7

Umesh wrote:
How can I delete one or more elements of an array.
let a[]={1,2,3,4,5} Now i want to send the third element '3' to an
array b[10] and remove the element from a.

How can I do it?
>From what I understand of the question, you want to be able to delete
elements from an array (i.e. resize the array), much like lists in
Python, arrays in Perl or vectors in C++ or Java.

You cannot do this directly in C. What you can do however is to shift
the elements 4 and 5 one place to the left and treat the last element
as a garbage value. The space taken up by the array would still be the
same, but you can go on treating this as a 4 element array in the rest
of your program. This is an overly simplified solution to the more
general problem. To have truly resizable data structure that has all
the properties of an array, you would have to dynamically allocate and
then reallocate memory as your array grows or shrinks.

Jun 13 '07 #8
Eric Sosman wrote:
Umesh wrote On 06/13/07 11:35,:
How can I remove duplicate entries from an array?

The message to which your query is a response
explained why you cannot remove elements from an
array. You must have seen the message -- you posted
a reply to it -- but did you read it?

Why does anyone still bother with this guy. He's either trolling, or
perversely determined to ignore the advice given. Either way, a huge
waste of time.


Brian
Jun 13 '07 #9
Default User said:
Eric Sosman wrote:
>Umesh wrote On 06/13/07 11:35,:
How can I remove duplicate entries from an array?

The message to which your query is a response
explained why you cannot remove elements from an
array. You must have seen the message -- you posted
a reply to it -- but did you read it?


Why does anyone still bother with this guy. He's either trolling, or
perversely determined to ignore the advice given. Either way, a huge
waste of time.
I had him plonked, actually. Then I noticed, through context quoted by
Martin, that he'd started *giving* advice, at which point I considered
that it was more important to ensure that he didn't mislead newbies
than that he didn't annoy me.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 13 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5825
by: user | last post by:
Say I have an object (foo), that contains an array (bar) of references to other objects. Now I want to puff some of the objects from the array so that I remove the array element, and destroy the oject. but when I do: del foo.bar
5
2727
by: flupke | last post by:
Hi, i'm having trouble with deleting elements from a list in a for loop ============== test program ============== el = print "**** Start ****" print "List = %s " % el index = 0 for line in el:
20
12970
by: Hanzo | last post by:
I'm iterating over a vector of base class pointers and deleting those which meet a certain criteria...i'm using pretty text-book code for the particular delete/erasure (it's straight out of Myers' Effective STL), and reads like this: void CGame::RemoveDeadObjects() { // cleanup crew!! vector<CDrawableObject*>::iterator i;
18
2456
by: Dan | last post by:
hello, I would to know if it is possible to delete an instance in an array, The following does not allow me to do a delete. I am trying to find and delete the duplicate in an array, thanks for ( j =0; j<MAX ; j++) { for ( i =0; i<MAX ; i++)
1
1489
by: Christine | last post by:
Is there a way to delete a single element in an array?
3
6874
by: Newcomsas | last post by:
Hello, I'm trying to solve a problem with JS textbox array without success. I have two buttons in my page: PLUS and MINUS; at every click on PLUS a new textbox named 'dear' is generated. So, if one clicks, say, 3 times the output is something like: dear dear dear
1
2013
by: Varun Kacholia | last post by:
I apologize if there exists a standard way of deleting multiple elements from a STL hash_multiset (or even multiset for that matter) that I am unaware of. The problem, I see, with multisets is that you cannot obtain info to uniquely identify an element (eg: indices in a vector, or key in set/hash_set). Hence what I'd like to do is iterate...
13
2439
by: programming | last post by:
how do i delete from a text file 1 of the following lines: jon|scott adam|smith <--delete paul|clark say i would like to delete the middle line of this txt, in member.txt what php code or logic would help me accomplish this?
3
3733
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
One more for today.... As I add more and more lines to my RichTextBox the array that holds its strings gets bigger and bigger and the vertical scroll bar gets smaller and smaller until the string array finally runs out of memory. I'd like to set some line limit and once that limit is reached, start removing the first line each time a new...
0
7658
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7876
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8101
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7630
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7941
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5479
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5201
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3628
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.