A few simple questions that some1 might b able to help me with
Hi, Im making a basic encryption program at the moment, but im not using a normal method, instead, im using an array, some random numbers and a while loop. Anyway, the problems that Im having are as follows:
1. Writing to two files at the same time.
2. distinguishing between a random letter and a letter from the message.
That last point will seem a little strange, so here is a sample of code, and hopefully, ull c what i mean
Code:
cout << "Message >> ";
cin.getline(array, 200);
x = 0;
// MAIN ENCYPTION PART ////////////////////////////////////////////////////
while(x < 200)
{
y = rand()%3; // RANDOM NUMBER SELECTION
z = 64 + (rand()%25);
if(y == 1){
cout << (char)z; // TYPECASTING OF Z
a_file << (char)z;
}
if(y == 2){
cout << array[x];
a_file << array[x]; x++;
}
}
cout << "" << endl;
The plan is that the message gets mixed up with random letters and then gets saved to disk, but I need to be able to distinguish between the randomly generated letters and the message characters so that I can write another file that will tell you where the message characters are.
If you can understand that well done cos i didnt explain it too well