help on opening files in c++

D

DeeVee

I am very new to the language.
I am trying to open up to ten files from a list of many data files and
writing them all to one big file. To do this I am getting them
individually from the console each time i run the program. For example
each time I run the program I have to type:
c:/dev-cpp/file1/vnov94_b.txt
c:/dev-cpp/file1/faug74_a.txt
etc...
etc...

Do anyone have a simple idea so that i can do this much quicker?
I was thinking maybe if I just had to type the actual file and not the
whole path but im sure on how to do that. Thanks

This is what i have
for (int filecount=0; filecount<10;filecount++) {
char *a;
cin>>a;
if (*a=='x') break;
ofstream outfile("c:/dev-cpp/file1/abc.txt",ios::eek:ut |
ios::app);
ifstream infile(a);
etc...
 
K

Karl Heinz Buchegger

DeeVee said:
I am very new to the language.
I am trying to open up to ten files from a list of many data files and
writing them all to one big file. To do this I am getting them
individually from the console each time i run the program. For example
each time I run the program I have to type:
c:/dev-cpp/file1/vnov94_b.txt
c:/dev-cpp/file1/faug74_a.txt
etc...
etc...

Do anyone have a simple idea so that i can do this much quicker?

The simplest thing might be something your console provides. Depending
on the operating system you are using, you might be able to use input
redirection. Eg. on DOS you could do:

* create a text file which holds all the file names, eg. files.txt
* start your program like this

myprog < files.txt

The command prompt (the console) will feed the content of files.txt
to your program as if you had typed it.
 

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
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top