problem in histogram word
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 100
int main(void)
{
char *name;
int i,c,x;
int histogram[10];
name=malloc(sizeof (char) * SIZE);
x=0;
for(i=0;i<10;i++)
histogram[i]=0;
for(;;){
fgets(name,SIZE,stdin);
x=strlen(name);
puts(name);
/*next our test in histogram*/
if (x >= '0' && x <= '9')
++histogram[x-'0'];
/*next step showing it*/
puts("its histogram is\n");
for(i=0;i<10;i++){
printf("%d ",histogram[i]);}
puts("\n");
/*intilising all back to 0 and freeing back*/
x=0;
for(i=0;i<10;i++)
histogram[i]=0;
free(name);
name=malloc(sizeof (char) * SIZE);
continue;}
return 0;
}
it alawys shows the histogram alawys 0 i dunno why;