How to count the number of unique characters in a string?

Hi guys,

I'm trying to implement a bit of code in a program i have made but I'm kind of stuck on how to actually do it.

What i want is to be able to count the number of unique letters in a string. For example if the string is "baboon" there are 4 unique letters (b and o repeat). I have a bit of an idea on the logic of what the code should do, i am just stuck in actually writing the code.

I was thinking of having a vector and then running a loop that fills the vector with each character in the string unless that character is already in the vector and then finally count the number of letters in the vector.

By the way i am doing this in a method that returns an integer, being the amount of unique characters.

How would i do this? My knowledge in vectors is quite limited so i think this is my downfall, any help is greatly appreciated.

Topic archived. No new replies allowed.