Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*********************
- FINAL PROJECT: Dictionary Search
- STUDENT ID: 1002249145
- NAME: Christian Martin
- *********************/
- /* 11:45 */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #define SIZE 26
- int main( void )
- {
- int imputLetters;
- int i;
- char dictionaryEntry [ 26 ];
- char string[SIZE];
- char word[SIZE];
- FILE *cfPtr;
- char *tokenPtr; // create char pointer
- int countLetters [26];
- char *p = tokenPtr;
- // WORD SEARCH
- /*************************************
- for(i=0 ; i < 26 ; i++)
- countLetters [i] = 0
- for ( ; i * p != '\0' ; p++)
- if (*p == 'a')
- countLetters [0]
- if (*p == 'b')
- countLetters[1]++
- if (*p == 'c')
- countLetters [2]
- if (*p == 'd')
- countLetters[3]++
- if (*p == 'e')
- countLetters [4]
- if (*p == 'f')
- countLetters[5]++
- if (*p == 'g')
- countLetters [6]
- if (*p == 'h')
- countLetters[7]++
- if (*p == 'i')
- countLetters [8]
- if (*p == 'j')
- countLetters[9]++
- if (*p == 'k')
- countLetters [10]
- if (*p == 'l')
- countLetters[11]++
- if (*p == 'm')
- countLetters [12]
- if (*p == 'n')
- countLetters[13]++
- if (*p == 'o')
- countLetters [14]
- if (*p == 'p')
- countLetters[15]++
- if (*p == 'q')
- countLetters [16]
- if (*p == 'r')
- countLetters[17]++
- if (*p == 's')
- countLetters [18]
- if (*p == 't')
- countLetters[19]++
- if (*p == 'u')
- countLetters [20]
- if (*p == 'v')
- countLetters[21]++
- if (*p == 'w')
- countLetters [22]
- if (*p == 'x')
- countLetters[23]++
- if (*p == 'y')
- countLetters [24]
- if (*p == 'z')
- countLetters[25]++
- **************************************/
- if ( ( cfPtr = fopen( "dictionary.txt", "r" ) ) == NULL ) // Opens file
- {
- puts( "File not found/valid!" );
- return 1;
- }
- printf("*********** enter an assortment of letters ***********\n");
- printf("*********** Type exit to end ***********\n");
- while( imputLetters != -1)
- {// Start while
- for ( i = 1 ; fgets (dictionaryEntry , sizeof( dictionaryEntry ) , cfPtr) !=NULL ; i++)
- {
- scanf("%d" , imputLetters);
- tokenPtr = strtok( dictionaryEntry, "\t" ); // begin tokenizing sentence
- while ( tokenPtr != NULL )
- {// Start while
- printf( "%s\n", tokenPtr );
- tokenPtr = strtok( NULL, "\t" ); // get next token
- } // end while
- }
- }// End while
- // temp comment tokenPtr = strtok( string, " " ); // begin tokenizing sentence
- fclose( cfPtr );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement