How can I do it - with pointer and only one loop ?

for exmpl function - unsigned int dif(const char *str)

Code:
counter = 0;
for(i = 0; i < N; i++)				
A[i] = 0;
do								
{
      A[tmp%10]++;				 
      tmp /= 10;
}
while(tmp);
for(i = 0; i < N; i++)
if(A[i]) counter++;		
printf("\n\nThere r %u different digits in the number %u\n",counter , n);