GVA SUPPORT

³ 1300653514
Text:
	Բ =  ..

 :/*  
 *     
 * 20.03.2011 22:31
 *  .  3. .
 *    . 
 * :     .       
 *     .   [-128;127].
 *        ...  ...   
 *      -30  +30
*/

#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <iostream>
#include <strings.h>
#include <conio.h>

#include <iostream>
using namespace std;
void encoding(char *in, char *key, char *out)
{
    ifstream f_in(in, ios::in | ios::binary);
    ofstream f_out(out, ios::out | ios::binary);
    if ( !f_in || !f_out )  {
       cout << "ERROR of opening of a file.\\n"; system("PAUSE");  return ;
    }
    char  buf;
    while (!f_in.eof())  {
          f_in.read(&buf,1);
          buf=buf+atoi(key);
          f_out.write(&buf,1);
//          cout<<buf;
    }     
    f_in.close();
    f_out.close();
    
    cout<<"\\n\\n -> Encoding complate!\\n\\n";
}
void dencoding(char *in, char *key, char *out)
{
    ifstream f_in(in, ios::in | ios::binary);
    ofstream f_out(out, ios::out | ios::binary);
    if ( !f_in || !f_out )  {
       cout << "ERROR of opening of a file.\\n"; system("PAUSE");  return ;
    }
    char  buf;
    while (!f_in.eof())  {
          f_in.read(&buf,1);
          buf=buf-atoi(key);
          f_out.write(&buf,1);
//          cout<<buf;
    }     
    f_in.close();
    f_out.close();
    
    cout<<"\\n\\n -> Encoding complate!\\n\\n";
}
void k_read(char a[],char *b){
     cout<<a<<" : ";
     cin>>b;     
}
int main(int argc, char *argv[])
{
    char *in_filename=new char[80];
    char *out_filename=new char[80];
    char *key=new char[10];
    char userkey;
    do
    {
         system("cls"); 
         cout<<"Group 2. Laba#3. Variant #9. by Gorbachenko V.A\\
         \\nPress 1 to ecode\\
         \\nPress 2 to decode\\
         \\nYour choise : ";
         do{         
            userkey=getch();                  
         }while (userkey!=\'1\' && userkey!=\'2\');
         cout<<userkey<<endl;
         
         k_read("Enter IN filename",in_filename);
         k_read("Enter KEY [INT ONLY]",key);    
         k_read("Enter OUT filename",out_filename);    
         if (userkey==\'1\'){
            encoding(in_filename,key,out_filename);
         }
         else
         {
            dencoding(in_filename,key,out_filename);
         }
            
         cout<<"Press ESC to EXIT or other key to CONTINUE..."<<endl;
    } while (getch()!=27);

    
    system("PAUSE"); 
	return 0;
}


====================================