473,698 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expected unqualified-id before 'return'?

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;
}
-----------------------
Jul 8 '07 #1
2 27052
P.S. I know the code is messy and inefficient, but it worked up until now.
Jul 8 '07 #2
Meetee
931 Recognized Expert Moderator Contributor
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdio>
  4. #include <bitset>
  5. using namespace std;
  6.  
  7. int main () {
  8.  
  9. char password[32];
  10. char file[100];
  11. char filedata[8448];
  12. bool filebin[8448];
  13. bool key[32][8];
  14. bool splitholder[1056][8];
  15. int length;
  16. int totiterations;
  17. int iteration = 1;
  18. bool passwordbin[32][8];
  19. bool holder[32][1024][8];
  20.  
  21. //Get information from user
  22. cout << "Type in the name and location of the .spir file you wish to decode.\n";
  23. cin >> file;
  24. fstream inputfile;
  25. inputfile.open(file, ios::in | ios::binary);
  26. while(inputfile >> filedata)
  27. // cout << filedata;
  28. inputfile.close();
  29. //cout << "\n\n";
  30. int a = 0; /*Convert data from file into binary*/
  31. while(a<8448){
  32. if(!filedata[a]){
  33. break;
  34. }
  35. if(filedata[a]=='0'){
  36. filebin[a]=false;
  37. }
  38. else
  39. {
  40. filebin[a]=true;
  41. }
  42. // cout << filebin[a];
  43. a++;
  44. }
  45. cout << "\n\n";
  46. cout << "\n\nType in the password for the file.";
  47. cin >> password;
  48. length = strlen(password);
  49.  
  50. //Split the file into bytes
  51. int b = 0,c = 0;
  52. while(b<1056){
  53. if(!filedata[b*8]){
  54. break;
  55. }
  56. c = 0;
  57. while(c<8){
  58. splitholder[b][c] = filebin[(b*8)+c];
  59. // cout << splitholder[b][c];
  60. c++;
  61. }
  62. b++;
  63. // cout << "\n";
  64. }
  65.  
  66. //Separate the key from the file
  67.  
  68. //cout << length << "\n\n";
  69. b = 0;
  70. while(b<length){
  71. c = 0;
  72. while(c<8){
  73. key[b][c] = splitholder[b][c];
  74. // cout << key[b][c];
  75. c++;
  76. }
  77. b++;
  78. cout << "\n";
  79. }
  80.  
  81. //Shift the file to cover key
  82. b = 0;
  83. while(b<1024){
  84. c = 0;
  85. while(c<8){
  86. splitholder[b][c] = splitholder[b+length][c+length];
  87. // cout << key[b][c];
  88. c++;
  89. }
  90. b++;
  91. cout << "\n";
  92. }
  93.  
  94. //Erase extra data
  95.  
  96. b = 1024;
  97. while(b<1056){
  98. c = 0;
  99. while(c<8){
  100. splitholder[b][c] = false;
  101. c++;
  102. }
  103. b++;
  104. cout << "\n";
  105. }
  106.  
  107. //Convert the password into binary
  108. int p = 0;
  109. int e = 0;
  110. while(e<length){
  111. int f = 0;
  112. while(e<8){
  113. ++ e;
  114. if((password[p]&(1 << e) ? '1' : '0')=='1'){
  115. passwordbin[p][e]=true;
  116. }else{
  117. passwordbin[p][e]=false;
  118. }
  119. f++;
  120. cout << passwordbin[p][e];
  121. }
  122. p++;
  123. }
  124.  
  125. //Decode the key
  126. bool d,o;
  127. b = 0;
  128. while(b<length){
  129. c = 0;
  130. while(c<8){
  131. d = key[b][c];
  132. o = passwordbin[b][c];
  133. key[b][c] = (d||o)&&!(d&&o);
  134. c++;
  135. }
  136. b++;
  137. }
  138.  
  139. //Decrypt the message
  140. totiterations = length;
  141. int f = 0,g = 0;
  142. bool x,y,z;
  143. while(iteration<totiterations){
  144. f = 0;
  145. while(f<1024)
  146. g = 0;
  147. while(g<8){
  148. if(iteration = 0){
  149. holder[iteration][f][g] = splitholder[f][g];
  150. }
  151. if(f=0){
  152. y=holder[iteration][f][g];
  153. x=key[iteration][g];
  154. z=(x||y)&&!(x&&y);
  155. holder[iteration+1][f][g] = x;
  156. holder[iteration+1][f+1][g] = z;
  157. }
  158. else{
  159. y=holder[iteration][f][g];
  160. x=holder[iteration+1][f][g];
  161. z=(x||y)&&!(x&&y);
  162. holder[iteration+1][f+1][g] = z;
  163. }
  164. g++;
  165. }
  166. f++;
  167. }
  168. iteration++;
  169. } // Delete this
  170.  
  171. //end the program
  172. return 0;
  173. }
  174.  

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
Jul 9 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4224
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.
4
2455
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>...
0
1434
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...
2
2468
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
1
2006
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 >
3
1924
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...
9
6476
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"...
5
3293
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...
0
1779
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'
0
2997
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()?
0
8676
marktang
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...
0
8608
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,...
1
8898
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,...
0
8870
tracyyun
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...
0
7734
agi2029
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...
1
6524
isladogs
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...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
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
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.