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 :?:

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.

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 ...

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.