RW . :)
#define MAXDICTSIZE 25
int numberOfWordsInDict(char dict[][MAXDICTSIZE], int dictsize)
{
int i, cnt = 0;
for (i = 0; i < dictsize; i++)
{
if (strlen(dict[i]))
{
cnt++;
}
}
return cnt;
}
void printDict(char dict[][MAXDICTSIZE], int dictsize)
{
int i = 0;
printf("Dictionary:\n");
if (numberOfWordsInDict(dict, dictsize) == 0)
{
printf("The dictionary is empty.\n");
}
else
{
for (i = 0; i < dictsize; i++)
{
if(strlen(dict[i]))printf("- %s\n", dict[i]);
}
}
}
and somewhere in the main ()
char dict[10][MAXDICTSIZE] = {
"aap", "bro ", "jojo", "koe", "kip",
"haha", "hond", " drop", "","" };
char *newWord1 = "hoi";
printDict(dict, sizeof(dict)/sizeof(dict[1]));
strcpy(dict[1], newWord1);
printDict(dict, sizeof(dict) / sizeof(dict[1]));
source
share