I am completely novice in C, and just learned about the dynamic memory allocation using malloc, realloc, calloc and free.
I want to make a small programm which takes an int number as the number of the strings that will be given and then "scanf" them all.
Next play with these strings. For example find the most frequent and print it.
For example when i run the programm and type :
5
car house dog tree tree
It should print :
tree 2
I want scanf-printf because this is the input/output methods i am most familiar with at this point.
My code :
int main (){
int N,i,j ;
char *array;
int *freq;
scanf("%d",&N);
array = (char*)calloc(N,sizeof(char*));
for (i=0;i<=N;i++){
scanf( ??? );
}
free(array);
return 0;
}
What should i enter in the scanf fuction in order to properly fill the array with strings ? After i fill it will i use something like strcmp and a for loop in order to scan the array and find the most frequent word ? (I can store the frequencies in the *freq)