hello every body here

just today I knew I am stupid in C++ because I taken 2 hours thinking about this program

I have to write two programs

first program encrypt file from hard drive (.txt) and ask the user to enter the key to encrypt the file for example:

A=65 if we ask the user enter key and he enter 3

3+65 = 68 the letter after encrypt will be D because D=68

the kind of encryption is ASCII

second program same thing but decryption the file.

this my tried for quiestion 1

Code:
#include <iostream>
#include <fstream>
using namespace std;
void main()
{
	int key;
	char x;

	ifstream in_stream;
	ofstream out_stream;

	in_stream.open("encrypt.txt"); //it's already in the hard drive and contain some words or digits.
    out_stream.open("decrypt.txt");//the program it will be create this file.
	in_stream >> x;

	

	while(!in_stream.eof())
	{
		if(x>='a' && x<='z' || x=='A' && x=='Z' ||  x>=0 && x<9)
		{
			cout <<"Enter the key to encrypt your file\n";
			cin>>key;
			in_stream.get(x);
			x=key+x;
			cout<<x<<endl;
		}
	}
	in_stream.close();
	out_stream.close();
}