I've been working on a decryption program for another encryption program I made. It isn't finished, and when I try to compile it to test it, it gives me the error "expected unqualified-id before 'return'" right at the line where "return 0;" is. I am using Xcode for mac os, which is the same as g++ 4.0 for Unix/Linux. I can't seem to figure this out, and I can't test anything until it's fixed.
Any ideas?
Here's the code:
-----------------------
#include <iostream>
#include <fstream>
#include <cstdio>
#include <bitset>
using namespace std;
int main () {
char password[32];
char file[100];
char filedata[8448];
bool filebin[8448];
bool key[32][8];
bool splitholder[1056][8];
int length;
int totiterations;
int iteration = 1;
bool passwordbin[32][8];
bool holder[32][1024][8];
//Get information from user
cout << "Type in the name and location of the .spir file you wish to decode.\n";
cin >> file;
fstream inputfile;
inputfile.open(file, ios::in | ios::binary);
while(inputfile >> filedata)
// cout << filedata;
inputfile.close();
//cout << "\n\n";
int a = 0; /*Convert data from file into binary*/
while(a<8448){
if(!filedata[a]){
break;
}
if(filedata[a]=='0'){
filebin[a]=false;
}
else
{
filebin[a]=true;
}
// cout << filebin[a];
a++;
}
cout << "\n\n";
cout << "\n\nType in the password for the file.";
cin >> password;
length = strlen(password);
//Split the file into bytes
int b = 0,c = 0;
while(b<1056){
if(!filedata[b*8]){
break;
}
c = 0;
while(c<8){
splitholder[b][c] = filebin[(b*8)+c];
// cout << splitholder[b][c];
c++;
}
b++;
// cout << "\n";
}
//Separate the key from the file
//cout << length << "\n\n";
b = 0;
while(b<length){
c = 0;
while(c<8){
key[b][c] = splitholder[b][c];
// cout << key[b][c];
c++;
}
b++;
cout << "\n";
}
//Shift the file to cover key
b = 0;
while(b<1024){
c = 0;
while(c<8){
splitholder[b][c] = splitholder[b+length][c+length];
// cout << key[b][c];
c++;
}
b++;
cout << "\n";
}
//Erase extra data
b = 1024;
while(b<1056){
c = 0;
while(c<8){
splitholder[b][c] = false;
c++;
}
b++;
cout << "\n";
}
//Convert the password into binary
int p = 0;
int e = 0;
while(e<length){
int f = 0;
while(e<8){
++ e;
if((password[p]&(1 << e) ? '1' : '0')=='1'){
passwordbin[p][e]=true;
}else{
passwordbin[p][e]=false;
}
f++;
cout << passwordbin[p][e];
}
p++;
}
//Decode the key
bool d,o;
b = 0;
while(b<length){
c = 0;
while(c<8){
d = key[b][c];
o = passwordbin[b][c];
key[b][c] = (d||o)&&!(d&&o);
c++;
}
b++;
}
//Decrypt the message
totiterations = length;
int f = 0,g = 0;
bool x,y,z;
while(iteration<totiterations){
f = 0;
while(f<1024)
g = 0;
while(g<8){
if(iteration = 0){
holder[iteration][f][g] = splitholder[f][g];
}
if(f=0){
y=holder[iteration][f][g];
x=key[iteration][g];
z=(x||y)&&!(x&&y);
holder[iteration+1][f][g] = x;
holder[iteration+1][f+1][g] = z;
}
else{
y=holder[iteration][f][g];
x=holder[iteration+1][f][g];
z=(x||y)&&!(x&&y);
holder[iteration+1][f+1][g] = z;
}
g++;
}
f++;
}
iteration++;
}
//end the program
return 0;
}
-----------------------