Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #define ARRAYSIZE 10
- int numberOfWordsInDict(char **dict){
- int nwords = 0;
- for (int i = 0; i < 10; i++){
- if (dict[i] != 0)
- nwords++;
- }
- return nwords;
- }
- void addWord(char **dict, char *word){
- int i = numberOfWordsInDict(dict);
- dict[i] = word;
- }
- void printDict(char **dict){
- if (dict[0] == 0)
- printf("Empty!\n");
- else{
- for (int i = 0; i < ARRAYSIZE; i++)
- printf("%s\n", dict[i]);
- }
- }
- void main(){
- char* dict[ARRAYSIZE] = {};
- char word[256];
- printf("Add a word in the dictionary: ");
- scanf(" %s", &word);
- addWord(dict, word);
- printDict(dict);
- /* h.javan.hemmat@tue.nl*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement