473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Reg: Searching for a word in a File

105 100+
How can I check for a particular word in a file?

For eg

//////a.txt

Here is my first range
A=10
B=20
Here is my second range
A=30
B=40

I started reading each line and once I reach B=20 line, I wanted to go back to the first line “here is my first range” and look for the word first and then call some function.

Similarly once I have read b=40, I wanted to read again line “here is my second range” and look for the word “second” and then call some function.

Could anyone please help me with this?

Thanks.
Apr 23 '07 #1
5 1253
Savage
1,764 Expert 1GB
Hi, here are some hints:


1.Use ftell and fseek to return back on lines or just access it in array that u have
populated.

2.Use substring to get the vital word.

3.Execute any function on that string.


If u don't know how to use those functions go here

and if u have question about any hint just post!!

Savage
Apr 23 '07 #2
mickey22
105 100+
Thank you very much for the hints.I will try using the functions you have said.
Apr 24 '07 #3
Savage
1,764 Expert 1GB
Thank you very much for the hints.I will try using the functions you have said.
U are welcome!!

And if u have problems remember to post them here.


Savage
Apr 24 '07 #4
mickey22
105 100+
Actually I have used the switch statemnet to solve this problem.I just set a count variable and used this count variable to access different cases in switch statement.

Using switch statement made it bit easier to my application.I just wanted to let u know if somebody hase the same prob they can look for the solution.

Thanks once again
Apr 25 '07 #5
Savage
1,764 Expert 1GB
Actually I have used the switch statemnet to solve this problem.I just set a count variable and used this count variable to access different cases in switch statement.

Using switch statement made it bit easier to my application.I just wanted to let u know if somebody hase the same prob they can look for the solution.

Thanks once again

Great work!

It's nice that u wish to help others.

Keep it up!!

Savage
Apr 25 '07 #6

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

Similar topics

1
by: dixie | last post by:
I have a .reg file that I need to run across a network. Currently, we run it for each logon on the network manually, which is not really working well as there are over a hundred users and they...
4
by: Lasse Edsvik | last post by:
Hello I was wondering how to match car and the rest behind car using reg.exp? /car black bla bla bla so i can handle "car" and "black bla bla bla" seperately afterwards TIA /Lasse
7
by: DraguVaso | last post by:
Hi, Does anybody knows how to run a *.reg-file silently on a computer? I need this to do automatic updates of my application without user-interaction. So I don't want the user to be asked a...
1
by: Anurag | last post by:
Hi, I have 2 related questions. DB2 UDB ESE v8.x (8.1 till 8.2 FP2 - all fixpaks included) on AIX 5.4.x _____________________________________________________________________________ (QUESTION 1)...
7
by: pbd22 | last post by:
Hi. I am somewhat new to this and would like some advice. I want to search my xml file using "keyword" search and return results based on "proximity matching" - in other words, since the search...
15
by: Gigs_ | last post by:
Hi all! I have text file (english-croatian dictionary) with words in it in alphabetical order. This file contains 179999 words in this format: english word: croatian word I want to make...
1
by: veer | last post by:
Hi i made program on searching and if a word is present in a file more than one time this program search it one time and exit the file but i want to show all the locations of the searched word in...
12
by: Alexnb | last post by:
This is similar to my last post, but a little different. Here is what I would like to do. Lets say I have a text file. The contents look like this, only there is A LOT of the same thing. () A...
5
by: Sevla | last post by:
hello guys i set this code , and i would like to know if its possible set "quotes" on the searched word. Thank You #word searching program within a txt file #!C:/perl/bin/perl.exe start:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.