I am building a cipher program but i can't figure out how to return an array of char[] my cipher method
char *cipherinput(int ciphercount){
int i=0;
char *cipher[MAX_CIPHER_SIZE];
if(ciphercount>=2){
printf("Enter the Cipher!\n");
//loop through and add
for(i=0;i<ciphercount;i++){
scanf(" %c", cipher[i]);
}
}
return cipher;
}
my main method has
#define MAX_CIPHER_SIZE 16
#define MAX_TEXT_SIZE 256
int main()
{
int ciphercount=0, textcount=0,i=0,j=0,k=0;
int *cipher_, *text_, N=0,N_;
printf("Enter size of Cipher!\n");
scanf("%d", &ciphercount);
if(ciphercount>=2){
cipher_ = cipherinput(ciphercount);
}
else{
printf("Start again / Cipher size should be greater or equal to 2\n");
main();
}
return 0;
}
I've tried several methods such as char** (string) with no success.
char *cipher[MAX_CIPHER_SIZE];makes an array of strings. I dont think this is what you wantc. If you really want to, you'll have to wrap it in astructNULLpointer as the last element in the array.