i got a .txt file that contain data,
and i would like to read from the file and then write the data to another file,
is it about ifstream and ofstream?..
what i have done is just open the input file and open the output file :((
how to relate two files together? i am a newbie in c++, hope someone can help..:(

try to read the input file into a char * temp or some other string and then in the output file try to write this temp.
Also, this is a fstream operation.

This will be useful to you:
C++ Tutorial - 'Input/Output with files'

Hope this helps, please mark the thread as solved if it does :)

how to read into char * temp? and what is char * temp means ?
my .txt file contains several sentences.. what should i do?

char * temp is basically a string. if you open your file in fsteam as textFile, you can just do

textFile >> temp;

this will read your first sentence into the temp variable.
if you put this in loop and loop till textfile.eof() is true, you will be reading one sentence at a time into the temp and there, inside the loop, you can write it to another file.

invalid operands of types `char[256]' and `char[256]' to binary `operator>>'

How come ??! :(

1) Do not bump threads
2) Give enough information for us to understand the problem
3) Read the Member Rules

can you please post what you are coding at the moment?

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main()
{
         char temp[256];
         char FileName[256];
         cin >> FileName;
         ifstream fin;
         fin.open(FileName);
         FileName >> temp;
         fin.close();
         
         char FileName2[256];
         cin >> FileName2;
         ofstream fout;
         fout.open(FileName2);
         FileName2 << temp;
         fin.close();
         
         
         
         system("PAUSE");
         
         
         
}

FileName is to read data, FileName2 is the file that i want to write in data

HERE is my compile errors

invalid operands of types `char[256]' and `char[256]' to binary `operator>>'

To just copy a file:

#include <fstream>

bool copy_file( const char* infile, const char* outfile )
{
    std::ifstream fin( infile ) ;
    std::ofstream fout( outfile ) ;
    return fout << fin.rdbuf() ;
}
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.