By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,414 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,414 IT Pros & Developers. It's quick & easy.

Help Needed for Computer Science Class

P: n/a
I need to write a program which performs word subsitutions on a text
file. The program should input the names of three text files: the
source file that will be "edited", a text file that contains the
editing instructions, and a file that will contain the result of the
editing.

Nov 3 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<Pa********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I need to write a program
So write it.
which performs word subsitutions on a text
file.
You seem to know what it should do.
The program should input the names of three text files: the
source file that will be "edited", a text file that contains the
editing instructions, and a file that will contain the result of the
editing.


And some details.

You asked for 'help'. Help with what? I don't see any code.
You didn't expect anyone to write it for you, did you?

Were I given that assignment worded as you've posted it,
I'd ask for a few more details, espeically what should
be the possible editing instructions, in what format,
etc.

We're waiting and ready to help as soon as we see your code
and some specific questions.
-Mike
Nov 3 '05 #2

P: n/a
Hi Dude,
The program should input the names of three text files: the
source file that will be "edited", a text file that contains the
editing instructions, and a file that will contain the result of the
editing.
this requires use of program arguments. The signature of your program
is

int main(int argc, char** argv)

check out how to use them but in a nutshell argv[0] returns the name of
your executable and argv[1] refers to the first command line argument.
You can check the number of arguments by looking at argc's value.
You'll also need someway of reading the input file into some sort of
buffer or perhaps reading the file line by line or word by word or even
letter by letter (you've to decide) and performing a manilpulation that
way. I'd say std::string's will be very helpful to you and perhaps
ostringstreams for the output file. Again, I'm not sure. Mark's pointed
out that you'll need to get detailed specifics on what youre supposed
to do/implement. If you are tied-up waiting for that, you should
probably start by at least reading argv etc. and perhaps opening your
files in the appropriate modes. Just an idea.

The program should input the names of three text files: the
source file that will be "edited", a text file that contains the
editing instructions, and a file that will contain the result of the
editing.

OK, what your lecturer is after here is (among other things) evidence
that you know how to open files in different modes. There's a whole lot
you can read up on, but you should maybe look first to see which files
are to be opened readonly, read-write, which are to be created if they
don't already exist etc. etc. You'll have to decide what files are
opened in what mode and then go ahead and code.
Dunno how much coding you've done but you're lecturer is going to look
for evidence of understanding of the calls you make, error
checking/exceptions and good overall design.
If you start to make progress and get stuck, this group is great for
pointing out errors etc. The trick is to show them you've already tried
a stab at it at the very least.

good luck. Go for an A+ in this project... when is it due?

GrahamO

Mike Wahler wrote: <Pa********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I need to write a program


So write it.
which performs word subsitutions on a text
file.


You seem to know what it should do.
The program should input the names of three text files: the
source file that will be "edited", a text file that contains the
editing instructions, and a file that will contain the result of the
editing.


And some details.

You asked for 'help'. Help with what? I don't see any code.
You didn't expect anyone to write it for you, did you?

Were I given that assignment worded as you've posted it,
I'd ask for a few more details, espeically what should
be the possible editing instructions, in what format,
etc.

We're waiting and ready to help as soon as we see your code
and some specific questions.
-Mike


Nov 3 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.