943,866 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1342
  • C++ RSS
Nov 29th, 2006
0

I need help please

Expand Post »
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 :
  1. const max=30;
  2. char used [max];
  3. cout<<"Type in a word";
  4. cin>>word;
  5. for (int i=0;i<size-1; i++)
  6. for (int j=i+1; j<size; j++)
  7. if (word[i]==word[j])
  8. delete_repeat( )
  9.  
  10. void delet_repeat(char w[ ],int size)
  11. {
  12. for (s=j;s<size-1;s++)
  13. {
  14. word[s]=word[s+1]
  15. }

im very lost in this
Last edited by ~s.o.s~; Nov 30th, 2006 at 12:27 pm. Reason: Added code tags learn to use them yourself.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aileenveliz87 is offline Offline
1 posts
since Nov 2006
Nov 29th, 2006
0

Re: I need help please

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,951 posts
since Aug 2005
Nov 30th, 2006
0

Re: I need help please

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 ...
Reputation Points: 10
Solved Threads: 3
Newbie Poster
nattylife is offline Offline
14 posts
since Aug 2005
Nov 30th, 2006
0

Re: I need help please

you might want to have a look in this thread. It's a very similar problem to yours.
Last edited by Nick Evan; Mar 26th, 2010 at 10:33 am.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: What does *&p do?
Next Thread in C++ Forum Timeline: PLZ HELP!!..I WANNA write a prog forcomparing n concatenating strings using POINTERS





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC