Hello.
This is my program:

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;
int main()
{
    ifstream a;
    ifstream b;
    ofstream c;
    a.open("a.txt");
    b.open("b.txt");
    c.open("c.txt");
    int x;
    a >> x;
    b >> x;
    c << x;
    a.close();
    b.close();
    c.close();
    system("pause");
    return EXIT_SUCCESS;
}

In file "a" I have a number 1, in file "b" I have a number 5. How should I use the tie function in order to get the integer "1" in file "c"?

if you want to get numbers from a and put them in c then you can do this

a >> x;
c << x << endl;

NathanOliver -
It sounds like he wants to do something with this function:
http://msdn.microsoft.com/en-us/library/dt12193b(VS.71).aspx

I've never heard of the concept, but it doesn't sound like tie() does any actual outputting, but rather just forces an output to finish before starting an input.

What NathanOliver just recommended was in your original code, so I'm not sure what was wrong with that? Can you give an example file and tell us what the expected output current output are?

Dave

I need to show an example of what function tie does.

Looks that way David. From what I found it makes sure that the output stream is flushed before it allows any inputting to occur.

Hm, it seems I didn't understand. Can you help please? How this "tie" thing works? How can I create and example? I saw some links but they are strangely explained.

tie works by making the output stream tied to a input stream flush its contents before input is allowed. I really cant give you an example though because that would be doing your homework for you.

OMG, not again. I am not getting money or something...

i did not get your program properly can u tell how the tie works?

Well, that's my question too. My idea was to have reading from 2 different files and using tie function to tie 1 of the reading file and to write the info into a 3rd empty file in order to show that I have tied 1 specific file, not both.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.