Newbie program

J

Jul

Basically I am trying to design a program to open up a 2 txt files
scan the txt files and extract txt within each txt files that are the
same. I am kinda new to c++ so I am trying to figure out the
algorithm during the program as in:

Variable, ints, const,

fstream in of the two files

read fstream of first file

read fstream of second file

extract txt

fstream out

How big would such a program be?

I apologise for the newbie question
 
O

osmium

Jul said:
Basically I am trying to design a program to open up a 2 txt files
scan the txt files and extract txt within each txt files that are the
same. I am kinda new to c++ so I am trying to figure out the
algorithm during the program as in:

Variable, ints, const,

fstream in of the two files

read fstream of first file

read fstream of second file

extract txt

fstream out

How big would such a program be?

I apologise for the newbie question

You will have to start by refining your question. For example, each text
file probably contains the letter 'e'. Is that a match? How about the word
"the", is that a match? IOW, what does "the same" mean in the context of
your question?
 
L

Leor Zolman

Basically I am trying to design a program to open up a 2 txt files
scan the txt files and extract txt within each txt files that are the
same. I am kinda new to c++ so I am trying to figure out the
algorithm during the program as in:

Variable, ints, const,

fstream in of the two files
Okay, if that means "open the files for input and check for errors" (see
below re. the output file)
(begin loop)
read fstream of first file

(check for eof/error)
read fstream of second file

(check for eof/error)
extract txt

(that could have been done as part of your 'read' steps above, or not;
depends what route you take. If you just read into a text buffer, then
you'd probably need to do some parsing/extraction. Unless of course you're
simply comparing the entire corresponding lines of text for exact equality,
in which case it could be very simply done by reading into std::string
objects and testing them with the == operator. But this is the step that
would probably require the most nuance.
fstream out
If by this you mean "open the stream", then it belongs up before the start
of the loop. If you're using it as a verb, fine, but you'd still want to do
the opening/error check up /there/ ;-)

(End of loop)
How big would such a program be?
Is that your only actual question? Not that big, I'd say (somewhere around
the same number of lines as this post). Why don't you code it up and find
out?
I apologise for the newbie question

No apology necessary. Note there's also a group specialized for "newbie
questions" (but in reality there's a lot more that goes on there as well):

Good luck!
-leor
 

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,164
Messages
2,570,898
Members
47,439
Latest member
shasuze

Latest Threads

Top