Thread: removing dupes out of an array - pls someone explain this to me..

  1. #1
    Registered User
    Join Date
    Jun 2002

    Cool removing dupes out of an array - pls someone explain this to me..

    I am new to programming and to C programming itself....I was wondering how do I go about removing duplicate entries in an array, in most simplest code?
    for example:
    a[7] = {1,2,5,1,2,3,3}
    and I want to remove duplicates and store new entries in a anew array, say b[] that would have unique 1,2,5,3 entries only.... Please help me out I am lost here....

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Be patient, if you post the same question twice in one day then all you will do is annoy us.

    My best code is written with the delete key.

  3. #3
    Its not rocket science vasanth's Avatar
    Join Date
    Jan 2002
    ok you can do it like this

    a[7] is the array
    b[] is the new array

    for(int i=0;i<7;i++)
       for(int j=i;j<7;j++)  
              cout<<"Same number detected";

    so here you can see which number is same.. You can now write a function copy which copies all the numbers and removes the repeated numbers..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. array of pointers/pointer arithmetic
    By tlpog in forum C Programming
    Replies: 18
    Last Post: 11-09-2008, 07:14 PM
  2. Code: An auto expanding array (or how to use gets() safely).
    By anonytmouse in forum Windows Programming
    Replies: 0
    Last Post: 08-10-2004, 12:13 AM
  3. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM
  4. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 12:09 PM
  5. Pls explain how this program works...
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 01-05-2002, 09:53 AM