473,473 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Programming C - searching for same words from text file

2 New Member
Hi,

I would be glad if you would help me with this program:

Task:

User will enter 4-7 letters (for example 'ADFG').

I have detached text file which contains about several thousand of words

(for example:

BDF
BGFK
JKLICV
NGJKL
POIUEVBN

etc.)

-words are written in list

I want to make program, which find words from this text file, which are same letters which user entered

(In this case, when I entered ADFG it will find and display BDF, BGFK, NGJKL).
Jan 21 '14 #1
2 1734
weaknessforcats
9,208 Recognized Expert Moderator Expert
I would start by writing a function:

Expand|Select|Wrap|Line Numbers
  1. int Test(char token, char* str);
  2.  
This function would take a char token and a string str. The function returns a non-zero value (TRUE) if the token is in the str and 0 (FALSE) otherwise.

Then in main() write loop that calls this function for every character in ADFG using a word from the text file as str.

Since ADFG is a string, you can use strlen to determine how many time to call this function. You can also use strlen inside the function to determine how many characters are in the string to be searched.

Embed this loop inside a larger loop that reads the text file word by word.

And there it is...

BTW: I can't just write the code for you but I can help with code you write. Keep me posted.
Jan 22 '14 #2
dafrancesko
2 New Member
Here is my code <weaknessforcats>
When I run it, there will appear infinite (null)(null)(null)...
Jan 22 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Noam Dekers | last post by:
Hi all, I would like to find a word stored in a text file. Structure: I have one file named keyWords.txt that stores some key words I'm interested in finding. In addition I also have a file...
7
by: Santah | last post by:
hi I'm new to C++ and I'm currently working on Visual C++ 6.0 I'm trying to open a text file, and read some data from it part of the text file looks like this: --------
22
by: Ram Laxman | last post by:
Hi all, I have a text file which have data in CSV format. "empno","phonenumber","wardnumber" 12345,2234353,1000202 12326,2243653,1000098 Iam a beginner of C/C++ programming. I don't know how to...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
1
by: ICBailey | last post by:
Hi, hoping this is a simple question, since I'm new to the world of programming. I have a text file with multiple lines that I want to read into an array. Each line is consitent in length, with...
6
by: d4 | last post by:
I added a Text file to my Project (Add New Item Text File). I've added a button so when a user clicks on it it will bring up the text file to read, only problem is I cannot figure out how to call...
10
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
3
by: itdaddy | last post by:
hey perl gurus! i am new to this forum cause i need help. I have done many scripts. but i want to use perl to do this: What I want to do is this. I have a QRP file that I can convert to a txt...
4
by: scharnisto | last post by:
Hi, i need a script, that deletes all the lines between two certain words in a text file. the two words appear several times in the text file. i have a code, that works so far. the problem is,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.