I feel generous today. I'll give you the code you need, but
you'll have to put the lines in the correct order yourself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
{
cout << char(i + 'a');
string str = "aaabdkkl";
usingnamespace std;
int main()
cout << "\n(hit enter to quit...)";
int i;
#include <string>
return 0;
for (i = 0; i < str.size(); ++i)
for (i = 0; i < 26; ++i)
#include <iostream>
cin.get();
if (counter[i] == 1)
int counter[26] = { 0 };
++counter[str[i] - 'a'];
}
int main(){
char counter[20]={0};
int i;
int j=0;
string str="aaabdkkl";
while(str[j]!='\0') // So we count number characters until we hit a null terminator.
// Problem is, strings are not null terminated AND depending on the implementation
// this would yield a "out of range" exception or just end in a endless loop.
{
j++;
}
for(i=j;i<counter[j];i++){ // We set i = j but j is the string length. How could "i" possible be less than
// "counter[ i ]" which is 0
if(counter[i]==1){
cout<<str; // Isn't "str" the whole string, you didn't change it in anyway
}
}
Seems like you messed up C & C++ better read the documentation how to use strings more carefully ;)