473,466 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Create 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 13861
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...@sun.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
Richard Heathfield wrote:
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.
Ah, valid point.

Brian
Jun 13 '07 #11
Umesh <fr****************@gmail.comwrites:
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?
Use a different language. This will require using a different
newsgroup. Bye!

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 13 '07 #12

"Umesh" ("fraternity disposal aatt gmail dott com")
wrote:
How can I delete one or more elements of an array.
Umesh, Umesh, Umesh. First you go to comp.lang.c++ and
spam the group with nonsensical questions, then you come
to comp.lang.c and ask questions that are answered in the
first 10 pages of ANY good (or even mediocre) book on C.
It's like wasting a calculus professor's time by asking him,
"What's 3 plus 4? What's 9 divided by 2? What's a prime
number? Is 42 a prime number?" He's going to shove you
out his office door.

Get a book on C, Umesh. Read it. Learn something about
the language. THEN come here and talk to us about it.
Ok? Pleeeeeeeze?

--
Cheers,
Robbie Hatley
lone wolf aatt well dott com
triple-dubya dott Tustin Free Zone dott org
Jun 14 '07 #13
On Jun 13, 10:35 am, Umesh <fraternitydispo...@gmail.comwrote:
How can I remove duplicate entries from an array?
Change one of the duplicate values to a different value. As was
explained before, you cannot remove an array element; you may only
change its value.
Jun 14 '07 #14

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

Similar topics

3
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...
5
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...
20
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'...
18
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 ...
1
by: Christine | last post by:
Is there a way to delete a single element in an array?
3
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...
1
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...
13
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...
3
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
1
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...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.