Primjer koda:
Code:
// CutTo6000.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string sName, dName;
ifstream source;
ofstream dest;
int i;
char zn;
cout << "Input file name with source data: ";
cout.flush();
cin >> sName;
source.open( sName.data() );
if(source.is_open() == false)
{
cout << "Error opening file " << sName << ". Ending program." <<
endl;
cout << "Press any key ..." << endl;
cout.flush();
_getch();
return 0;
}
cout << "Input file name for saving data: ";
cout.flush();
cin >> dName;
dest.open( dName.data() );
for( i = 0; i < 6000; i++)
{
source >> zn;
dest << zn;
dest.flush();
}
source.close();
dest.close();
cout << "Program completed. Press any key ..." << endl;
cout.flush();
_getch();
return 0;
}
// CutTo6000.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <conio.h>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string sName, dName;
ifstream source;
ofstream dest;
int i;
char zn;
cout << "Input file name with source data: ";
cout.flush();
cin >> sName;
source.open( sName.data() );
if(source.is_open() == false)
{
cout << "Error opening file " << sName << ". Ending program." <<
endl;
cout << "Press any key ..." << endl;
cout.flush();
_getch();
return 0;
}
cout << "Input file name for saving data: ";
cout.flush();
cin >> dName;
dest.open( dName.data() );
for( i = 0; i < 6000; i++)
{
source >> zn;
dest << zn;
dest.flush();
}
source.close();
dest.close();
cout << "Program completed. Press any key ..." << endl;
cout.flush();
_getch();
return 0;
}
[Ovu poruku je menjao X Files dana 03.12.2007. u 20:54 GMT+1]