I made a code which can count length of a string in characters without space, But I want add an feature which count any repeated char as one, so Please help me out to do so, my code is written below:
#include<iostream>
#include<string>
using namespace std;
int count(string s){
char chr;
int num = 0;
for(int i = 0; i<(s.length()); i++){
chr = s[i];
num++;
if(chr == ' '){
num -= 1;
}
else if (char == )
}
return num;
}
int main()
{
string str;
cout << "\nIt is simple counting string program\n\n"<< "\tEnter a string: ";
getline(cin,str);
cout << "\nThe total number of String is : " << str << endl;
cout << count(str) << endl;
Just an observation: Any character with an odd number of appearances will be considered unique, and any character with an even number of appearances will not be considered at all, whereas the OP calls for the size of the string less the number of duplicate characters.