JogaBonito1502
Guru
- Messages
- 7,841
- Location
- U.S.
Here's my problem:
I'm creating a program that will encrypt and decrypt files by arranging the content in square matrix and doing various transformations to it. I'm currently writing the header file that will contain a class with functions in it. Each function will represent a step in the encryption/decryption of the file.
My first function is very simple. It simply reads the contents of the file and decides what dimensions the square array should be.
This function will return the size of the m x m matrix.
My next function will change the characters into their respective ASCII values, and will sort them into the m x m matrix. In this definition, I need my dimensions to be left open (dynamic) because the dimensions will be sent in a variable pointer which contains the result of the function above. This is what my declaration looks like:
Here, I have two questions:
1. inFile needs to be a 2D array containing the characters of the text file in a M x M array (where M = the size of the matrix defined by the IdentifyMatrix()).
I could make this array 1D, but if I do so, I want to load the contents of the text file into the program and make this 1D array a pointer.
I also want the values of this 2D (or 1D pointer) array to be constants (so they can't be toyed with while the program runs).
2. CypherMatrix needs to be a dynamic array (one without the dimensions defined) until I run IdentifyMatrix(). As stated earlier, IdentifyMatrix() will return me a value with the dimensions of the square matrix. How do I declare this dynamic 2D array (this NEEDS to be 2D so I can do matrix transformations).
Thanks for the help.
I'm creating a program that will encrypt and decrypt files by arranging the content in square matrix and doing various transformations to it. I'm currently writing the header file that will contain a class with functions in it. Each function will represent a step in the encryption/decryption of the file.
My first function is very simple. It simply reads the contents of the file and decides what dimensions the square array should be.
Code:
int IndentifyMatrix();
This function will return the size of the m x m matrix.
My next function will change the characters into their respective ASCII values, and will sort them into the m x m matrix. In this definition, I need my dimensions to be left open (dynamic) because the dimensions will be sent in a variable pointer which contains the result of the function above. This is what my declaration looks like:
Code:
void Encrypt(int* MatrixSize, char const* (*inFile), int CypherMatrix[][]);
Here, I have two questions:
1. inFile needs to be a 2D array containing the characters of the text file in a M x M array (where M = the size of the matrix defined by the IdentifyMatrix()).
I could make this array 1D, but if I do so, I want to load the contents of the text file into the program and make this 1D array a pointer.
I also want the values of this 2D (or 1D pointer) array to be constants (so they can't be toyed with while the program runs).
2. CypherMatrix needs to be a dynamic array (one without the dimensions defined) until I run IdentifyMatrix(). As stated earlier, IdentifyMatrix() will return me a value with the dimensions of the square matrix. How do I declare this dynamic 2D array (this NEEDS to be 2D so I can do matrix transformations).
Thanks for the help.