help on opening files in c++

Discussion in 'C++' started by DeeVee, Jul 22, 2003.

  1. DeeVee

    DeeVee Guest

    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...
    DeeVee, Jul 22, 2003
    #1
    1. Advertising

  2. DeeVee wrote:
    >
    > 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.


    --
    Karl Heinz Buchegger
    Karl Heinz Buchegger, Jul 22, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brad Smallridge

    Opening two files

    Brad Smallridge, Mar 28, 2005, in forum: VHDL
    Replies:
    2
    Views:
    500
    info_
    Mar 28, 2005
  2. Mat W
    Replies:
    3
    Views:
    422
    Skeleton Man
    May 21, 2004
  3. Peter H

    opening aspx-files in frontpage?

    Peter H, Jul 3, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    364
    Peter H
    Jul 4, 2003
  4. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    744
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  5. fniles
    Replies:
    0
    Views:
    262
    fniles
    Apr 26, 2009
Loading...

Share This Page