C Program to opens and reads dictionary file specified in spellrc

How to write a C Program to opens and reads dictionary file specified in spellrc in C Programming Language ?

Solution:


/*opens and reads dictionary file specified in spellrc*/

 if (strcmp(settings_p->autoCorrect, "yes") == 0) { 
  actionFunc_p = &autoCorrect;
  printf("action function set to autoCorrect\n");
 } else {
  actionFunc_p = &noAutoCorrect;
  printf("action function set to no autoCorrect\n");
 }

 printf("Current value of dictionary: %s\n", settings_p->dictionary);
 
 dictFile_p = fopen(settings_p->dictionary, "r");
  if (!dictFile_p) {
   perror(settings_p->dictionary);
   return 1;
  }

 printf("Opened dictionary file successfully\n");
/*
TERMINAL OUTPUT:
Current value of dictionary: thedictionary.txt
action function set to autoCorrect
Current value of dictionary: #
��� : No such file or directory

*/


Learn More :