Hi my task is to get the user to input a string and then copy only the unique elements to another string.
For example user enters AABBBACDEEEF in to string1, string 2 prints ABCDEF.
We're not allowed to use pre built functions i.e. stuff from string.h.
This is an extra exercise and I don't have to do it but I'm curious and it's driving me mad so I wondered if any of you could help?
I know I need to test each element in array 1 for duplicates and then only copy one over (I think) or do I copy the first instance of every character in string 1 over to string 2 then check string 2 for duplicates before copying the next character?
Question
aydinh
Hi my task is to get the user to input a string and then copy only the unique elements to another string.
For example user enters AABBBACDEEEF in to string1, string 2 prints ABCDEF.
We're not allowed to use pre built functions i.e. stuff from string.h.
This is an extra exercise and I don't have to do it but I'm curious and it's driving me mad so I wondered if any of you could help?
I know I need to test each element in array 1 for duplicates and then only copy one over (I think) or do I copy the first instance of every character in string 1 over to string 2 then check string 2 for duplicates before copying the next character?
Any help would be appreciated, thanks
Link to comment
Share on other sites
16 answers to this question
Recommended Posts