![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Oskilliet Warlord
|
im just a student in high school
my father introduce me to computer programming and I think I interested in develop a simple text file based dictionary I select C in implementation but I don't know any way to start any knowledge that I must know before writing it .? now I can deal with string , file , but I don't know much about data structure furthermore , if I can search the word through the CSV file (word,meaning) then I need to sort word in file in a format of dictionary. could anyone give me any suggession to get through my problem ? |
|
|
|
|
|
#2 |
|
Mentally Challenged
Join Date: Oct 2007
Location: Japan
Posts: 6
Rep Power: 0
![]() |
Re: help me please : text file based dictionary with c
How you go about programming this will depend on the structure of the dictionary file.
Can you post a sample of the dictionary?
__________________
I don't need no signature. |
|
|
|
|
|
#3 |
|
Oskilliet Warlord
|
Re: help me please : text file based dictionary with c
|
|
|
|
|
|
#4 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 598
Rep Power: 4
![]() |
Re: help me please : text file based dictionary with c
Just read the CSV file line by line in a loop. You said you know about files so I assume you already know how to do that. After reading a line you need to separate the two words then compare the first word with the word you want to find. There are a couple of standard string functions you could use to do that.
1) use strchr() to locate the comma, then replace it with a 0 string null terminator. char line[255] = "word,notation";
// search for the comma
char* firstWord = NULL;
char* secondWord = NULL;
int spot = strchr(line,',');
if( spot > 0)
{
line[spot] = 0; // null terminate
firstWord = line;
secondWord = line + spot + 1;
}Anter way (and simpler) is to use strtok char line[255] = "word,notation"; // search for the comma char* firstWord = strtok( line, ","); char* secondWord = strtok( NULL, ","); |
|
|
|
|
|
#5 |
|
Oskilliet Warlord
|
Hi, now I can search through csv file line by line
thanks so much for your suggestion above. so code is like this c Syntax (Toggle Plain Text)
but in this case , my dict is show the meaning if only input word = word in database every each characters. but in the real world , dictionary give me more dictionary can give a word that also like an input word such as CSV - example bankster,a student in one highschool of the world programming_forums_org,the land of programmng I try to give input like this ./dictionary bank my current dictionary search through the line and string compare with the word that I separated from the line the result !=0 so it's can't find this word in database . actually , thing that I need this program to work for me is to listing the word that LIKE or possible word in database for user. could you give me any suggestion like before? and finally I hope that anyone wouldn't think this just a school homework . I don't study computer programming at school but I love it , my father introduce it to me. something that I will do for my dictionary - sort every word in csv file alphabetically A-Z - add word into file - append external csv file to current file and sort them - dictionary web application thank you p.s. sorry for my bad English , I am Thai . |
|
|
|
|
|
#6 |
|
Programmer
Join Date: Oct 2007
Posts: 39
Rep Power: 0
![]() |
Re: help me please : text file based dictionary with c
Instead of using
strcmp() you need to use strncmp(). Get the length of the word you are looking for using strlen() and use that value for the length. That way bank will match with bank banker banking bankster etc
__________________
Testing 001 010 011 100.... |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help with fstream to a text file | rhm54 | C++ | 6 | Oct 22nd, 2007 10:39 PM |
| C++ IDEs/Java Libraries/Making a Text Based Game! | Tsar_of_Cows | Java | 17 | Jun 22nd, 2007 2:52 PM |
| Dynamic form from text file. | randum77 | Visual Basic .NET | 4 | Apr 24th, 2007 12:39 PM |
| Adding more info to a text file without erasing | crawforddavid2006 | C# | 2 | Apr 11th, 2007 3:10 PM |
| How to read unknown total of int data from text file to a 2-dim array in C | ladyscarlet99 | C | 2 | Sep 9th, 2005 3:28 AM |