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;
}
-----------------------
2 27052
P.S. I know the code is messy and inefficient, but it worked up until now.
Meetee 931
Recognized Expert Moderator Contributor
One kind advice..!! Please write your code in CODE tags as given in instructions (right side when you write new thread) so it soesn't become messy :))
BTW the problem is one extra } that you have added before return 0. I think it is generating this error. Just remove it to get rid of the error!!!
Regards
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: C. M. Sperberg-McQueen |
last post by:
wooks (wookiz@hotmail.com) wrote:
> <?xml version='1.0'?>
> <userlogin xmlns="urn:faster:userlogin"
> xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
> <login>mick</login>
> <password>brown</password>
> </userlogin>
> Above is my schema instance.
|
by: Erik Moore |
last post by:
I am both producing and parsing an xml document that needs to be validated against a schema. I wanted some consumers of the document
to have the option of not performing a validation, so I left the nodes in the instance unqualified. An example of the document is
below:
<?xml version="1.0" encoding="utf-8" ?>
<filingreceipt xmlns="http://www.disclosureusa.org/filingreceipt.xsd">
<cpofilingnumber>TX2004043037501</cpofilingnumber>...
|
by: Goodmannewz |
last post by:
In the textbook, there is a sentence that "Default XML
namespaces(xmlns="...") helps a lot, but can also create problems, as a side
effect of the rules for automatic qualification. How to understand "automatic
qualification" here? Could you please give me an example? Secondly, unless
otherwise specified, a schema prescribes that loal elements and attributes
must be "unqualified". What does "unqualified" mean? Could you please giv eme
an...
|
by: Jeff S |
last post by:
I have the following three lines at the very top of a class file (prior to
the namespace declaration line).
using System;
using System.Data;
using System.Data.SqlClient;
Then, in a subsequent function in the same file I want to create a
connection by entering the following line:
SqlClient.SqlConnection cn = new
|
by: Simon |
last post by:
Hi -
I have a webservice with WSDL specifying 'elementFormDefault' set to
'unqualified'. I find when I try to process the incoming XML the raw XML
either looks like this:
<s0:rootelement xmlns:s0="myns">
<ChildElement></ChildElement>
</s0:rootelement >
| |
by: mavis |
last post by:
Unqualified element in XSD definition
For some reason, we may need to define elements in XSD to be
"unqualified".
According to the design patterns of XSD, it seems they do not recommend
to define elements in this way....it seems it will influence XPATH /
XSLT, etc...
|
by: Mark Olbert |
last post by:
I'm trying to serialize (using XmlSerializer.Serialize) a class that I generated from an XSD schema using XSD.EXE /c.
The problem I'm running into is that the root element needs to be unqualified, and the default namespace needs to be included on it
as an attribute. The schema I'm using is this:
<xs:schema
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:html="http://www.w3.org/TR/REC-html40"...
|
by: Jeremy |
last post by:
I've got two projects, both reference system, system.data and system.xml and
both include the using System.Xml.Serialization and using System at the top
of the file.
Both also include the XmlElementAttribute attribute on some properties as
defined below, but on one project I get the error "'System' denotes a
'namespace' where a 'class' was expected" and the other project I don't.
There highlights the word System on...
|
by: Stef Mientki |
last post by:
hello,
I've syntax error which I totally don't understand:
########## mainfile :
import test_upframe2
if __name__ == '__main__':
var1 = 33
code = 'print var1 + 3 \n'
|
by: Terry Reedy |
last post by:
Stef Mientki wrote:
Indendation is screwed. Is the above all do_more body?
Which locals does this get you? __init__'s? (locals()?)
Isn't this just the same as globals()?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |