This is a little bit confusing for me, but I have to see how many times i occurs in x. So if someone types 3 for i and x is 4294967295, it should then say 0 times, but if someone types in 9 for i and 4294967295 for x, it should say 3 times.
This is what I have, but output says 0 with 9, so it's not working ..
int main(int argc, char** argv) {
unsigned int i;
scanf("%u", &i);
unsigned int x;
scanf("%u", &x);
int output = 0;
int t = 0;
while (t < 10) {
x /= 10;
if (i == x) {
output++;
}
t++;
}
printf("%d", output);
}
Also I recommend using more explicit variable names, like
digit
andnumber
instead ofx
andi
.