### counting

#### Digit Counting Issue in C++ Program

I'm making a program that counts the amount of each number in a string of digits entered by the user. The result is the number of each digit from 0 to 9 in order showing how much of each was entered. For example, entering 575 would result in 0000020100. But for some reason, every time I run the program it thinks there's a number 8 somewhere. So instead I get 0000020110 for 575. Anyone know why this is happening? #include <iostream> using namespace std; int main() { char x[80]; int dig, str, digcnt=0; cout<<"Enter a number: "; cin>>x; for(dig=48;dig<58;dig++) { for(str=0;str<80;str++) { if((int)x[str]==dig) digcnt++; } cout<<digcnt; digcnt=0; } return 0; }

### Related Links

How to answer queries of type l,r,k which finds number of elements in an array in range l to r which occurs atleast k times?

Dafny and counting of occurences

Counting the number of capital letters in each row in [R]

python: count values of dictionary

How to apply hyperloglog to a timeseries stream

Counting the number of occurrences of C in each line and outputting this number plus the total number of characters in that line

Digit Counting Issue in C++ Program

Binary Strings of the form *111*