Thank you I found it.
Now I have another problem.
I want to give a string and then count all letters it has
For example ,for string: "aabbllld" ,I want to receive
==========================================================
a = 2
b = 2
l = 3
d = 1
I thought something ,but I got some errors.
What's happening??
Thank you...
<pre>#include <stdio.h>
#include <string.h>
void count_each_letter_of_word(char *word , int **num_array);
enum alphabet {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} chosen_letter;
int main(void)
{
char my_input[200];
printf("Give a word: ");
scanf("%s" , my_input);
int length_word = strlen(my_input);
printf("length of %s is %d\n", my_input , length_word);
int numbers_array[length_word];
for(int ii = 0; ii < length_word; ii++)
{
numbers_array[ii] = 0;
printf("numbers_array[%d] = %d , " , ii , numbers_array[ii]);
}
printf("here -> %d|\n", chosen_letter = j);
count_each_letter_of_word(my_input , numbers_array);
}
void count_each_letter_of_word(char *word , int **num_array)
{
for(int ii = 0; ii < strlen(word); ii++)
{
num_array[ chosen_letter = word[ii] ]++;
}
for(int ii = 0; ii < strlen(word); ii++)
{
printf("%c = %ls\n" , word[ii] , num_array[ii]);
}
}
I change something ,but know I have errors to the numbers_array I suppose...