Posted on 2005-04-22
Last Modified: 2011-04-14
can i ask someone what is external file name for I/O Stream???
Question by:cuong5985
    LVL 30

    Expert Comment

    Hi cuong5985,
    > >can i ask someone what is external file name for I/O Stream???

    What do you mean by external file name?

    David Maisonave :-)

    Author Comment

    Just like i have a program like this:
    #include <fstream>
    #include <iostream.h>
    #include <stdlib.h>

    int main()
    using namespace std;
    ifstream in_stream;
    ofstream out_stream;"infile.dat");"outfile.dat");

    int first, second, third;
    in_stream >> first >> second>> third;
    out_stream <<"The sum of the first 3\n"
               <<"numbers in infile.dat\n"
               <<"is" <<(first+second+third)
    in_stream.close( );
    out_stream.close( );

          return 0;

    So where is my infile.dat located????
    LVL 30

    Expert Comment

    >>So where is my infile.dat located????

    This depends no your implementation, OS, and IDE.

    If you want to be sure of it's location, you should give it a fully qualified name (full path).

    Without a fully qualified name, it could be located in one of the follownig directories:
    The path of your executable
    The path were you launched your executable
    The path of your current directory when file is opened

    You should not use ifstream.h and iostream.h
    They're not part of the C++ standard, and therefore they're not portable and will not compile on compilers like VC++ 7.x

    Use <iostream> and <fstream> instead, which are part of the C++ standard.
    LVL 4

    Expert Comment

    have u wriiten the program ur self or gotten it from somewhere
    LVL 4

    Accepted Solution

    you are supposed to supply the infile.dat file ur self

    Author Comment

    I just want to give an example and get that example from a book.  THanks for your comment.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
      Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
    The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now