i think i got what you mean laserlight but i "play" with arrays...
i can post this part...is it helpfull?
Code:
/* Allocating space for ch */
ch = (char **)malloc(size*sizeof(char *));
for(i=0; i<size; i++){
ch[i] = (char *)malloc(size*sizeof(char));
}
if(ch == NULL){
printf("Error in allocating ch' s space.\n");
exit(1);
}
/* Allocating space for ciphertext */
ciphertext = (char *)malloc((size^2)*sizeof(char));
if(ciphertext == NULL){
printf("Error in allocating ciphertext space.\n");
exit(1);
}
/* Allocating space for newplaintext */
newplaintext = (char *)malloc((size^2)*sizeof(char));
if(newplaintext == NULL){
printf("Error in allocating newplaintext space.\n");
exit(1);
}
printf("\n\tEncoding in progress...\n");
/* Stores the 1-dim plaintext in 2-dim ch */
store_text(plaintext, k, ch, size);
/* Printing what 2-dim ch contains */
print_2darray(ch, size);
/* Coding the text( 2-dim ch to 1-dim ciphertext ) */
get_text(ch, size, ciphertext); // ch is [size][size] where ciphertest is [sixe]^2
/* Printing the coded 1-dim ciphertext */
printf("\n\nEncoding completed:");
print_text(ciphertext, size);
printf ("\n\tDecoding in progress...\n");
/* Store the coded text 1-dim ciphertext to 2-dim ch array */
store_text(ciphertext, size , ch, size);
/* Prints the 2-dim ch array(coded text) */
print_2darray(ch, size);
/* Decoding the 2-dim ch array and stores the values to 1-dim newplaintext(decoded) with n^2 size */
get_text(ch, size, newplaintext);
/*Prints the 1-dim newplaintext array(decoded) */
printf("\n\nDecoded completed:");
print_text(newplaintext, size);
/* Free the allocatin spaces */
free (plaintext);
free (ch);
free (ciphertext);
free (newplaintext);