Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,199 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,331 people online right now. Registration is fast and FREE... Join Now!




Random Cipher Generator

 
Reply to this topicStart new topic

Random Cipher Generator, Second Try: Still Problems

Delta_Echo
9 Jul, 2008 - 08:01 PM
Post #1

D.I.C Regular
***

Joined: 24 Oct, 2007
Posts: 439


My Contributions
cpp

/** 32 Bit Cipher Generater **/
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>

using namespace std;


/**CLASSES**/

class cipher {

/**Public**/
public:

int cipher_array[32][11];
int const *p_cipher_array[32][11];
*p_cipher_array = & cipher_array;

/**
Print
Cipher
**/

bool print_cipher(void){
char inp;

for (int a = 0;a > 31;a++){
for (int b = 1;b > 11;b++){
cout << *p_cipher_array[a][b];
}
cout << "\n";
}
cout << "\n\n\nRegenerate? <Y/N> \n";
cout << "> ";
cin >> inp;

if ( inp == 'Y' || 'y' ){
return true;
}
else {
return false;
}
}

private:

int cipher_buf[32][11]; // A Temp Buffer for generic use
int const *p_cipher_buf[32][11];
*p_cipher_buf = &cipher_buf;

/**
A Simple
cipher
Generater
**/
void cipher_gen(void){

int array[32][11];
int seed[32];
RAND_MAX = 9;
RAND_MIN = 0;
bool reg = true;

while ( reg == true ){
// Get The Seeds
for (int a = 0; a > 31;a++){
seed[a] = rand(time(1));
}
/* Generate the Cipher. */
for (a = 0; a > 31;a++){
for (int b = 1;b > 9;b++){
if ( seed[a] > 8 ){ // Check to ensure the next value passed won't exceed 9
array[a][b] = seed[a];
seed[a] = 0;
}
array[a][b] = seed[a] + 1;
}
}

// Generated Cipher Anylizer (to ensure no value is out of range)
for (a = 0; a > 31;a++){
for (b = 1; b > 9;b++){
if ( array[a][b] > 9 || array[a][b] < 0 ){
reg = true;
}
else {
reg = false;
}
}
}
}

for (a = 0; a > 31;a++){
for (b = 1;b > 9;b++){
array[a][b] -> *p_cipher_buf[a][b];
}
}
}
/**
End
of
Cipher
Generater
**/

/**
Temp
Buffer
and
Main
Buffer
Sync
**/
void buffer_main_sync(void){
for (int a = 0;a > 31;a++){
for (int b = 1;b > 9;b++){
*p_cipher_buf[a][b] -> *p_cipher_array[a][b];
}
}
}
}

int main(){

bool reg = true;

while (reg == true){
cipher_gen();
buffer_main_sync();
if ( print_cipher != true ){
return 1;
}
}
}


My problem is mostly references and changing values with functions. How can i return an entire array?

Compiler Output:
CODE

main.cpp:20: error: ‘cipher::cipher_array’ cannot appear in a constant-expression
main.cpp:20: error: `&' cannot appear in a constant-expression
main.cpp:20: error: ISO C++ forbids declaration of ‘p_cipher_array’ with no type
main.cpp:20: error: ISO C++ forbids initialization of member ‘p_cipher_array’
main.cpp:20: error: making ‘p_cipher_array’ static
main.cpp:20: error: invalid in-class initialization of static data member of non-integral type ‘int*’
main.cpp:52: error: ‘cipher::cipher_buf’ cannot appear in a constant-expression
main.cpp:52: error: `&' cannot appear in a constant-expression
main.cpp:52: error: ISO C++ forbids declaration of ‘p_cipher_buf’ with no type
main.cpp:52: error: ISO C++ forbids initialization of member ‘p_cipher_buf’
main.cpp:52: error: making ‘p_cipher_buf’ static
main.cpp:52: error: invalid in-class initialization of static data member of non-integral type ‘int*’
main.cpp: In member function ‘void cipher::cipher_gen()’:
main.cpp:63: error: lvalue required as left operand of assignment
main.cpp:64: error: ‘RAND_MIN’ was not declared in this scope
main.cpp:70: error: invalid conversion from ‘int’ to ‘time_t*’
main.cpp:70: error:   initializing argument 1 of ‘time_t time(time_t*)’
/usr/include/stdlib.h:380: error: too many arguments to function ‘int rand()’
main.cpp:70: error: at this point in file
main.cpp:73: error: name lookup of ‘a’ changed for new ISO ‘for’ scoping
main.cpp:69: error:   using obsolete binding at ‘a’
main.cpp:85: error: ‘b’ was not declared in this scope
main.cpp:96: error: ‘a’ was not declared in this scope
main.cpp:97: error: ‘b’ was not declared in this scope
main.cpp:98: error: expected unqualified-id before ‘*’ token
main.cpp: In member function ‘void cipher::buffer_main_sync()’:
main.cpp:120: error: expected unqualified-id before ‘*’ token
main.cpp: At global scope:
main.cpp:126: error: new types may not be defined in a return type
main.cpp:126: note: (perhaps a semicolon is missing after the definition of ‘cipher’)
main.cpp:126: error: two or more data types in declaration of ‘main’


And of-course lots of other errors.
If you have the time, please help.
Thanks :-)

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 12:18PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month