| | |
I need help please
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Solved Threads: 0
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 :
im very lost in this
c Syntax (Toggle Plain Text)
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
Last edited by ~s.o.s~; Nov 30th, 2006 at 12:27 pm. Reason: Added code tags learn to use them yourself.
•
•
Join Date: Aug 2005
Posts: 14
Reputation:
Solved Threads: 3
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 ...
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 ...
![]() |
Other Threads in the C++ Forum
- Previous Thread: What does *&p do?
- Next Thread: PLZ HELP!!..I WANNA write a prog forcomparing n concatenating strings using POINTERS
Views: 1087 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






