P
Pete
I'm trying to a very simple encryption key generator. I have hard coded a 10
binary string into an array, I then want to permute that string using
another array with element of type int for 1 to 10. Then I'm using this as
an index to copy to an output array, but offcourse the integer 10 is reading
the non-existent 11th element of, could someone help with a solution to my
problem, I would prefer to get the binary string from keyboard but I had
problems. below is the fragment I'm having problems with.
#include <stdio.h>
#include <string.h>
main()
{
int string[10]={1,1,0,1,0,0,0,1,1,1};
int P10[10]={3,5,2,7,4,10,1,9,8,6};
/*int input[10];*/
int P10_out[10];
int i,index;
/*printf("\nEnter a 10 Binary Sting: ");
for(i=0; i<10; i++){
scanf("%d", input);
}*/
for(i=0; i<10; i++) {
index = P10;
P10_out = string[index];
printf("P10_out = %d\n", P10_out);
}
}
As you can see I tyied to enter from the keyboard but the binary string
converted to an int I think
binary string into an array, I then want to permute that string using
another array with element of type int for 1 to 10. Then I'm using this as
an index to copy to an output array, but offcourse the integer 10 is reading
the non-existent 11th element of, could someone help with a solution to my
problem, I would prefer to get the binary string from keyboard but I had
problems. below is the fragment I'm having problems with.
#include <stdio.h>
#include <string.h>
main()
{
int string[10]={1,1,0,1,0,0,0,1,1,1};
int P10[10]={3,5,2,7,4,10,1,9,8,6};
/*int input[10];*/
int P10_out[10];
int i,index;
/*printf("\nEnter a 10 Binary Sting: ");
for(i=0; i<10; i++){
scanf("%d", input);
}*/
for(i=0; i<10; i++) {
index = P10;
P10_out = string[index];
printf("P10_out = %d\n", P10_out);
}
}
As you can see I tyied to enter from the keyboard but the binary string
converted to an int I think