954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I need help please

I need help in writing a fuction call delete_repeats that has a partially filled array of chararcters as a formal parameter and that delets all repeted letters from the array. It should also have two formal parameters: an array parameter and a formal parameter of type int that gives the number of array position used and when the letters are deleted the remaining letters are moved forward to fill in the gap. So far this is what I have :

const max=30;
    char used [max];
    cout<<"Type in a word";
    cin>>word;
    for (int i=0;i<size-1; i++)
    for (int j=i+1; j<size; j++)
        if (word[i]==word[j])
        delete_repeat(       )
    
    void delet_repeat(char w[  ],int size)
    {
         for (s=j;s<size-1;s++)
         {
             word[s]=word[s+1]
             }


im very lost in this :?:

aileenveliz87
Newbie Poster
1 post since Nov 2006
Reputation Points: 10
Solved Threads: 0
 

please edit your post to use code tags. If you don't know how to use them you can find the instructions in the link in my signature below.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

lets say you have
char sMyString[6];

0 1 2 3 4 5
[A] [R] [R] [A] [Y] [\0]

you call delete_repeats ( sMyString, 0 );

so basically you want to delete A at position 3, but you cant just move everything to the right of it to the left. that would be too easy... think of a way to copy or move the positions after your target letter to the left ...

nattylife
Newbie Poster
14 posts since Aug 2005
Reputation Points: 10
Solved Threads: 3
 

you might want to have a look in this thread. It's a very similar problem to yours.

Nick Evan
Not a Llama
Moderator
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You