Scanning a text document

B

bsmith95610

Does anyone know what the command is to scan a line of a file in a text
document for a specific word? Is there such a command? Anything would
help thanks.
 
M

Mike Wahler

bsmith95610 said:
Does anyone know what the command is

C has no 'commands'.
to scan a line of a file in a text
document for a specific word? Is there such a command?

No, C has no 'commands', nor does it have a built-in
facility to do this, however it's a simple task to
write one.
Anything would
help thanks.

Look up standard library functions:

'fopen()'
'fgets()'
'feof()'
'fclose()'
'strstr()'

-Mike
 
M

Martin Ambuhl

bsmith95610 said:
Does anyone know what the command is to scan a line of a file in a text
document for a specific word? Is there such a command? Anything would
help thanks.

C has no commands at all; nor does it have any functions to do this.
<ot>
Your machine probably has a program like 'grep' which can be used at the
command prompt, and so may be called a 'command'. Check with the gnu
site for source for grep if you need it.
</ot>
 
K

Keith Thompson

bsmith95610 said:
Does anyone know what the command is to scan a line of a file in a text
document for a specific word? Is there such a command? Anything would
help thanks.

Is this really a question about the C programming language?

C doesn't have "commands". The C standard library has a number of
functions; there's no single function that will do what you're asking
for, but it shouldn't be hard to combine them if you want to write a
program to do the job.

If you're looking for a *command*, that's probably something that's
provided by your operating system. We don't know what OS you're
using; even if we did, we couldn't help you here, because we only
discuss the C programming language.

If you ask in another newsgroup, I suggest you define the problem more
precisely. What exactly is a "word"? Do you want to scan the entire
file, or just one specified line; if the latter, how is the line
specified? Do you just want the result printed, or do you want to be
able to do something else with it? And so forth.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,170
Messages
2,570,927
Members
47,469
Latest member
benny001

Latest Threads

Top