I am learning c++, below is an attempt at a simple XOR encryption program. I am am using Dev c++ (Blooodshed Ide) using the ming-gw win 32 gcc compiler blah blah.
This code compiles without errors or warnings but it will not produce an 'exe' only a '.o' file, firstly what is a '.o' file? Without much ado I am guessing its a type of report produced when the program contains run-time errors. I am unable to access it though :o(
secondly does anyone know how this code could run; without having to make too many extreme changes to it?
Thanks S
#include <string>
#include <iostream>
#include <fstream>
#include <stdio.h>
using namespace std;
string textToEncrypt;
string outString;
int main(int argc, char* argv[])
{
int key = 129;
fstream infile1;
infile1.open(argv[0],ios::in);//Open file
infile1 >> textToEncrypt;
{
char c;
int i;
int j = textToEncrypt.length();
while (!infile1.eof( ))
{
for (int x=0;j-1;x++){
c = textToEncrypt[i];
c = (char)(c ^ key);//Encypt characters using v. simple XOR
outString[x] = c;
i++;
}
}
}
infile1.write((char*)&outString,sizeof(outString)); //Write encryption
infile1.close();
return 0;
}