I need to make a program in C , in which a word is entered and the number of different characters of a text char[]
returns. Example: "holahola"
only 4 different characters were used. If there is at least one space, it must be taken into account.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j,b,a=0;
char c[60];
printf("Ingresa una cadena:\n");
scanf("%[^\n]",&c);
fflush(stdin);
printf("%s",c);
a=0;
b=strlen(c);
for(i=0;i<=b;i++){
for(j=i+1;j<=b;j++){
if(c[i]==c[j]){
a++;
}
}
}
b=b-a;
printf("Numero de simbolos: %d",b);
return 0;
}