How to write a C Program to Implements a dictionary's functionality in C Programming Language ?
Solution:
- /****************************************************************************
- * dictionary.c
* Implements a dictionary's functionality.
- ***************************************************************************/
- #include <stdbool.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include "dictionary.h"
- // declare structure for each word
- typedef struct node
- {
- char word[LENGTH + 1];
- struct node* next;
- }
- node;
- bool hash(const char* word)
- {
- // index < the number of buckets
- // deterministic - the same value needs to map to the same bucket every time
- }
- /**
- * Returns true if word is in dictionary else false.
- */
- bool check(const char* word)
- {
- // TODO
- return false;
- }
- /**
- * Loads dictionary into memory. Returns true if successful else false.
- */
- bool load(const char* dictionary)
- {
- // TODO
- // declare file pointer for dictionary file
- FILE* input = NULL;
- // open dictionary
- input = fopen(dictionary, "r");
- if (input == NULL)
- {
- return false;
- }
- // declare memeory space or each word
- node* new_node = malloc(sizeof(node));
- while(input != EOF)
- {
- // scan dictionary after opening for each word before a\n and stores in in new_code->word
- fscanf(input, "%s", new_node->word);
- // hash the word (takes string and returns an index)
- hash(word);
- // this is a example on how to put a word in the front of the list
- new_node->next = head;
- head = new_node;
- }
- return false;
- }
- /**
- * Returns number of words in dictionary if loaded else 0 if not yet loaded.
- */
- unsigned int size(void)
- {
- // TODO
- return 0;
- }
- /**
- * Unloads dictionary from memory. Returns true if successful else false.
- */
- bool unload(void)
- {
- // TODO
- return false;
- }
Learn More :
Function
- How to pass one dimensional array to function in c.
- Write a c program which passes two dimension array to function.
- Write overloaded function templates for finding the roots of the linear (a * x + b = 0) and square (a * x2 + b * x + c = 0) uravneniy.Zamechanie: in function to send coefficients of the equations.
- C Program Character toupper() Example
- C Program Function Example
- Napisać funkcję obliczającą funkcję geometryczną w tablicy NxM elementowej z elementów o wartościach parzystych znajdujących się pod główną i ponad przeciwną przekątną.
- C Program To Find LCM and HCF Of Two Number Using Function - 2
- C Program To Convert Temperature In Celsius To Fahrenheit, Using Function
- C Program To Find Simple Interest
- C Function to Check Vowel
- Factorial Program In C Using Function
- C Program For Prime Number Using Function
- C Function to xorSwap and addSwap in C Programming
- C Program to concatenate two strings without using string functions
- C Function to read instructions from the file and obey them
- C program calculates a given function in range given by user, stores the data in arrays and displays the answer in a table.
- C Program to Implements a dictionary's functionality.
- = (int*)malloc(sizeof(int)) ??
- Design a C function that shortens a string to 8 characters
- C Program that prompts the user to input a string, (whitespaces allowed)
- Local sounds functions in C Program
- Function Get the resource that will be gathered from the zone name
- C Program to Find the Size of File using File Handling Function
- Average function in C
Dictionary
Implementation
- C Program To Implement Heap Sort
- Implements an 8-bit sample and hold ADC on the MSP430
- C Program to Implements a dictionary's functionality.
- C Program to Implementation of List ADT as linked-list
- Pre Order, Post order, In order Implement Binary Tree using linked list
- Implementation of your "Fury of Dracula" Dracula AI
- C Program to Implement Dijkstra's Algorithm
- C Program to Implement Quick Sort
- C Program to Implemention Bubble Sort using array
- C Program to Create, Display, Insert and Deletion of Queue Elements
- Linked List For Getting Employee Details, Display and Search For Salary C Program