473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 26969
P.S. I know the code is messy and inefficient, but it worked up until now.
Jul 8 '07 #2
Meetee
931 Expert Mod 512MB
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
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> > ...
4
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...
0
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...
2
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...
1
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...
3
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 ...
9
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,...
5
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...
0
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
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.