P
Pete
Sorry for the ambiguity of my last post, What I am try to do is enter a 10
bit binary string
eg: 1110001010 and then permute them into an array using an array containing
3,5,2,7,4,10,1,9,8,6 as the index, so the 1st bit will be in the P10_out[3],
2nd bit in P10_out[5] and so on. I am sure the problem is to do with the
input string, it is each 1 and 0 of the input is not being read as
individual elements. Your help is much appreciated.
#include <stdio.h>
#include<string.h>
main()
{
int P10[10]={3,5,2,7,4,10,1,9,8,6};
int P10_out[10];
int i,index;
int input[10];
printf("\nEnter a 10 Binary Sting: ");
for(i=0; i<10; i++){
scanf("%c", &input);
}
for(i=0; i<10; i++) {
index = P10;
P10_out = input[index-1];
printf("P10_out = %d\n", P10_out);
}
}
bit binary string
eg: 1110001010 and then permute them into an array using an array containing
3,5,2,7,4,10,1,9,8,6 as the index, so the 1st bit will be in the P10_out[3],
2nd bit in P10_out[5] and so on. I am sure the problem is to do with the
input string, it is each 1 and 0 of the input is not being read as
individual elements. Your help is much appreciated.
#include <stdio.h>
#include<string.h>
main()
{
int P10[10]={3,5,2,7,4,10,1,9,8,6};
int P10_out[10];
int i,index;
int input[10];
printf("\nEnter a 10 Binary Sting: ");
for(i=0; i<10; i++){
scanf("%c", &input);
}
for(i=0; i<10; i++) {
index = P10;
P10_out = input[index-1];
printf("P10_out = %d\n", P10_out);
}
}
asI'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
You commented out the definition of input above. This code won't
compile.
}*/
for(i=0; i<10; i++) {
index = P10;
When i is 5, index is 10.P10_out = string[index];
string[10] does not exist. The indices for string run from 0 to 9.
This invokes undefined behavior.
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
Until you show us your real code, we have no idea what you are talking
about.
<<Remove the del for email>>