#include <iostream>
#include <cstring>
#include <string>
unsigned repeatingCharCount(char const* s)
{
std::string unique ;
const unsigned length = std::strlen(s) ;
for ( unsigned i = 0; i<length; ++i )
{
if ( std::string::npos == unique.find(s[i]) )
unique += s[i] ;
}
std::cout << unique << '\n' ; // ** change here **
return length - unique.length() ;
}
int main()
{
char buffer[1000] ; // ick.
std::cout << "Enter a string\n" ;
std::cin.getline(buffer, 1000) ; // ** change here **
// std::cin >> buffer ;
std::cout << '"' << buffer << "\" has "
<< repeatingCharCount(buffer) << " repeats.\n" ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHN0cmluZz4KCnVuc2lnbmVkIHJlcGVhdGluZ0NoYXJDb3VudChjaGFyIGNvbnN0KiBzKQp7CglzdGQ6OnN0cmluZyB1bmlxdWUgOwoKCWNvbnN0IHVuc2lnbmVkIGxlbmd0aCA9IHN0ZDo6c3RybGVuKHMpIDsKCglmb3IgKCB1bnNpZ25lZCBpID0gMDsgaTxsZW5ndGg7ICsraSApCgl7CgkJaWYgKCBzdGQ6OnN0cmluZzo6bnBvcyA9PSB1bmlxdWUuZmluZChzW2ldKSApCgkJdW5pcXVlICs9IHNbaV0gOwoJfQoKCXN0ZDo6Y291dCA8PCB1bmlxdWUgPDwgJ1xuJyA7CQkvLyAqKiBjaGFuZ2UgaGVyZSAqKgoKCXJldHVybiBsZW5ndGggLSB1bmlxdWUubGVuZ3RoKCkgOwp9CgppbnQgbWFpbigpCnsKCWNoYXIgYnVmZmVyWzEwMDBdIDsgLy8gaWNrLgoKCXN0ZDo6Y291dCA8PCAiRW50ZXIgYSBzdHJpbmdcbiIgOwoJc3RkOjpjaW4uZ2V0bGluZShidWZmZXIsIDEwMDApIDsJLy8gKiogY2hhbmdlIGhlcmUgKioKCS8vIHN0ZDo6Y2luID4+IGJ1ZmZlciA7CgoJc3RkOjpjb3V0IDw8ICciJyA8PCBidWZmZXIgPDwgIlwiIGhhcyAiCgkJPDwgcmVwZWF0aW5nQ2hhckNvdW50KGJ1ZmZlcikgPDwgIiByZXBlYXRzLlxuIiA7Cn0g