Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

Home Library Index Site Map  Links Search About

File Streams

So... one fine morning I awoke with the full code for this program in my head! You know that something starts to take over your life when you start to dream about it.

 

Dreamapp.cpp
// INCLUDES
//
//#include bcb only
#include
#include
#include
#pragma hdrstop
// NAME: DreamApp.CPP
// TYPE: C++ SOURCE FILE
// SYNOPSIS: I dreamt of this program!
// DESCRIPTION: copies text files from the Command line
// EXAMPLES:
// BUGS:
// SEE ALSO:
//---------------------------------------
// Function headers
int Copy(char* from, char* to);

//---------------------------------------
int main(int argc, char* argv[])
{
// test argc to ensure sufficient args <2
if(argc <3 || argc>4)
{
cout<<"Incorrect number of parameters."<< endl;
cout << endl << "Press any key to continue...";
getch();
return 0;
}
Copy(argv[1], argv[2]);
return 1;
}
Note:
Home Library Index Top

function Copy( )
//////////////////////
//Function: int Copy(char* from, char* to)
//
//Description: Copies text from one file to another
//
/////////
int
Copy(char* from, char* to)
{
ifstream in;
ofstream out;

in.open(from);
if(!in)
{
cout<<"Cannot open file "< cout << endl << "Press any key to continue...";
getch();
return 0;
}

out.open(to);
if (!out)
{
cout<<"Cannot open file "< cout << endl << "Press any key to continue...";
getch();
return 0;
}
while (!in.eof())
{
out.put(static_cast(in.get()));
}
in.close();
out.close();
cout << endl << "File copied. Press any key to continue...";
getch();
return 1;
}
Note:
Home Library Index Top

 

STL Database
Arrays
Binary File Input / Output
Character Input
Containers
Standard Template Library
Streams
Templates
Utility Functions
Win32 Programming
Miscellaneous
 

 
copyright notice

Copyright Robert Mitchell. Last Revised : 5 May, 2000

e-mail me
1