Quick Search for:  in language:    
WordInListc,program,accept,user,entered,word,
   Code/Articles ╗ |  Newest/Best ╗ |  Community ╗ |  Jobs ╗ |  Other ╗ |  Goto ╗ | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
C/ C++ Stats

 Code: 728,035. lines
 Jobs: 113. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for C/ C++.
Yahoo! Finance HTML clean up
By Donald Bono on 2/19


OneInstance problem fix
By Salah_GIS on 2/18


Bar Chart
By Cris Friolo on 2/18


Pacman
By Deddi Hariprawira on 2/18


Click here to see a screenshot of this code!TExt STatistical generatOR (TESTOR)
By bagsta on 2/17

(Screen Shot)

Medical Store Inventory
By Prathamesh on 2/17


Click here to see a screenshot of this code!Num_Magic
By Arindam Ray on 2/17

(Screen Shot)

Space Attack
By Daniel Bjorndahl on 2/16


Spy Ferret Spyware Cracker
By Jerome Scott II on 2/16


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

WordInFile.c -- look up a dictionary file for the word you just entered (source code only)

Print
Email
 
VB icon
Submitted on: 1/27/2004 3:23:19 AM
By: Donald Bono 
Level: Beginner
User Rating: Unrated
Compatibility:C, C++ (general)

Users have accessed this code 202 times.
 

 
      WordInList.c -- this program can accept user entered word from command line, then it open up the dictionary file (use our "25486-english-words.txt" -- but you can supply your own dictionar file) trying to look up the word you just entered.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

//**************************************
//     
// Name: WordInFile.c -- look up a dicti
//     onary file for the word you just entered
//     (source code only)
// Description:
WordInList.c -- 
this program can accept user entered word from command line,
	 then it open up the dictionary file 
(use our "25486-english-words.txt" -- but you can supply your own dictionar file) trying to look up
	 the word you just entered. 
// By: Donald Bono
//
// Inputs:
Syntax for this program --
WordInList.exe your-word 
//
// Returns:a line of message
//
// Assumes:the trick for preparing dicti
//     onary file is that the last line needs t
//     o contain the text string "ZZZZZZ"
//
// Side Effects:unknown
//
//This code is copyrighted and has// limited warranties.Please see http://
//     www.Planet-Source-Code.com/vb/scripts/Sh
//     owCode.asp?txtCodeId=7532&lngWId;=3//for details.//**************************************
//     

/* 
WordInList.c -- 
this program can accept user entered word from command line,
	 then it open up the dictionary file trying to look up
	 the word. 
Syntax --
WordInList.exe word 
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void strchop(char * l1)
    {
    char * t1 = l1;
    int ddone = 0;
    while ( (t1[0] != 0x0) && (!ddone) ) { 
    if (t1[0] < 0x20) { 
    t1[0] = 0x0; 
    ddone = 1;
}

t1++; }
}
int main (int argc, char ** argv) { FILE * inFile; FILE * outFile; char * inFileName; char * line; char * the_word; char inBuf[500]; char lineBuf[1500]; char wordBuf[500]; char * words_in_list[30000]; int i, done = 0; int word_cnt = 0; inFileName = (char *) inBuf; line = (char *) lineBuf; the_word = (char *) wordBuf; if (argc < 2) { printf ("\nSyntax :\n%s YOUR-WORD \n\n", argv[0]); } else {
strcpy(inFileName, "25486-english-words.txt"); strcpy(the_word, argv[1]); inFile=fopen (inFileName,"r"); NULLIFY_ALLOC_MEMORY: for (i=0; i<30000; i++) { words_in_list[i] = NULL; }
if (inFile==NULL) { printf("Error opening dictionary file \"%s\".\n\n", inFileName); } else { while ((word_cnt < 30000) && (!done)) { fgets (line, 1499, inFile); if (strlen(line) >= 2) { strchop(line); words_in_list[word_cnt] = (char *) malloc (strlen(line) + 3); strcpy(words_in_list[word_cnt], line); if (word_cnt % 1000 == 0) { // printf("%d ===> %s\n\n", word_cnt, line); // return 0; } if (strstr(line, "ZZZZZZ") != NULL){ done = 1; } word_cnt++; }
}
fclose (inFile); printf("\n\n"); // printf("%d count on %s\n\n", word_cnt // , the_word); for (i=0; i<word_cnt; i++) { if (words_in_list[i] != NULL) { if (strstr(words_in_list[i], the_word) != NULL) { printf("\"%s\" already exists in the list. {{ line # %d }} ", the_word, i); goto EXISTED; } } }
printf("\"%s\" NOT in the list. \n\n", the_word); goto FREE_ALLOC_MEMORY; EXISTED: printf("\n\n"); FREE_ALLOC_MEMORY: for (i=0; i<30000; i++) { if (words_in_list[i] != NULL) { free(words_in_list[i]); } }
}
}
return 0; } /* main */
/* END file WordInList.c */


Other 32 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | C/ C++ Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyrightę 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.