File Access and variable usage/manipulation

G

Guest

Hello,

I'm trying to create a C++ command line program that will extract specific
lines from a text file and write them to another text file. E.g. If I want
the program to look for the word "The"(Always at the start) and extract the
entire line.
Text file input example:
// ------------------------
Hello there!
The quick brown fox

Jumped over the
lazy dog
The pizza arrived
on time
// ------------------------

Would output

The quick brown fox
The pizza arrived

I know this can be done with VB using strings and InStr. I've found that
strings can be examined using
string.find(word to find);
However, when reading data from a file, I don't seem to be able to use a
string to put the data read from a file into.
I've tried using

// -------
ifstream filein;
filein >> variable;
// And
filein.read(variable, character-limit);
// -------

Neither appears to accept using a string variable as a variable for that, I
can get it to work as a char, double, etc; but when I use char I stops at
spaces and ignores the ends of lines.

Thank you,
Andy.
 

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

Top