Fstream help?

Hey guys, I'm having a hell of a time here. I have an assignment for a college course and I'm tasked with creating a console app that can detect user input, recognize keywords from a .txt file (colors in this case, red, blue, yellow etc.) And replace those keywords with phrases from another .txt file (file is provided to me, so no worries there.)

So my main question is this: How do I use the fstream library to open colors.txt and phrases.txt, and then use them to replace user input colors with the phrases? All using provided text files. Goal of this program is to show that I can use fstream, ofstream, ifstream etc.

I'm SERIOUSLY lost here ._.
Last edited on
Hello H4X0R46,

One place to start is http://www.cplusplus.com/doc/tutorial/files/ or https://www.learncpp.com/cpp-tutorial/186-basic-file-io/

I would suggest the second link. It is more up to date and the examples are better.

I would suggest starting with a short program the opens one input file, reads it and print to the screen.

When that is finished do the same for the second file.

Then you can add from there.

If you need an output file create it last then have the reads print to the output file.

It does not matter right now how the output looks just so you can tell what came from which file.

This is just simple input and output for now.

When you have some code post what you have done for discussion.

Also it helps to post the input files so that everyone can use the same information and not have to guess at what might be in these files.

Andy
Topic archived. No new replies allowed.