SHARE
TWEET

Untitled

a guest Jun 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*********************
  2.  
  3.  FINAL PROJECT: Dictionary Search
  4.  
  5.  STUDENT ID: 1002249145
  6.  
  7.  NAME: Christian Martin
  8.  
  9. *********************/
  10. /* 11:45 */
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #define SIZE 26
  16.  
  17.  
  18.  
  19. int main( void )
  20. {
  21.     int imputLetters;
  22.     int i;
  23.     char dictionaryEntry [ 26 ];
  24.     char string[SIZE];
  25.     char word[SIZE];
  26.     FILE *cfPtr;
  27.     char *tokenPtr; // create char pointer
  28.     int countLetters [26];
  29.     char *p = tokenPtr;
  30.  
  31.  
  32.  // WORD SEARCH
  33.  
  34.  /*************************************
  35.         for(i=0 ; i < 26 ; i++)
  36.         countLetters [i] = 0
  37.  
  38.  
  39.         for ( ; i * p != '\0' ; p++)
  40.             if (*p == 'a')
  41.              countLetters [0]
  42.  
  43.             if (*p == 'b')
  44.              countLetters[1]++
  45.  
  46.             if (*p == 'c')
  47.              countLetters [2]
  48.  
  49.             if (*p == 'd')
  50.              countLetters[3]++
  51.  
  52.             if (*p == 'e')
  53.              countLetters [4]
  54.  
  55.             if (*p == 'f')
  56.              countLetters[5]++
  57.  
  58.             if (*p == 'g')
  59.              countLetters [6]
  60.  
  61.             if (*p == 'h')
  62.              countLetters[7]++
  63.  
  64.             if (*p == 'i')
  65.              countLetters [8]
  66.  
  67.             if (*p == 'j')
  68.              countLetters[9]++
  69.  
  70.             if (*p == 'k')
  71.              countLetters [10]
  72.  
  73.             if (*p == 'l')
  74.              countLetters[11]++
  75.  
  76.             if (*p == 'm')
  77.              countLetters [12]
  78.  
  79.             if (*p == 'n')
  80.              countLetters[13]++
  81.  
  82.             if (*p == 'o')
  83.              countLetters [14]
  84.  
  85.             if (*p == 'p')
  86.              countLetters[15]++
  87.  
  88.             if (*p == 'q')
  89.              countLetters [16]
  90.  
  91.             if (*p == 'r')
  92.              countLetters[17]++
  93.  
  94.             if (*p == 's')
  95.              countLetters [18]
  96.  
  97.             if (*p == 't')
  98.              countLetters[19]++
  99.  
  100.             if (*p == 'u')
  101.              countLetters [20]
  102.  
  103.             if (*p == 'v')
  104.              countLetters[21]++
  105.  
  106.             if (*p == 'w')
  107.              countLetters [22]
  108.  
  109.             if (*p == 'x')
  110.              countLetters[23]++
  111.  
  112.             if (*p == 'y')
  113.              countLetters [24]
  114.  
  115.             if (*p == 'z')
  116.              countLetters[25]++
  117. **************************************/
  118.  
  119.    if ( ( cfPtr = fopen( "dictionary.txt", "r" ) ) == NULL ) // Opens file
  120.     {
  121.       puts( "File not found/valid!" );
  122.       return 1;
  123.     }
  124.  
  125.    printf("***********   enter an assortment of letters   ***********\n");
  126.    printf("***********          Type exit to end          ***********\n");
  127.  
  128.  
  129.  
  130.     while( imputLetters != -1)
  131.     {// Start while
  132.    for ( i = 1 ; fgets (dictionaryEntry , sizeof( dictionaryEntry ) , cfPtr) !=NULL ; i++)
  133.         {
  134.         scanf("%d" , imputLetters);
  135.  
  136.         tokenPtr = strtok( dictionaryEntry, "\t" ); // begin tokenizing sentence
  137.  
  138.         while ( tokenPtr != NULL )
  139.             {// Start while
  140.             printf( "%s\n", tokenPtr );
  141.             tokenPtr = strtok( NULL, "\t" ); // get next token
  142.             } // end while
  143.         }
  144.     }// End while
  145. // temp comment        tokenPtr = strtok( string, " " ); // begin tokenizing sentence
  146.  
  147.  
  148.  
  149.       fclose( cfPtr );
  150.    }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top