Why is the passing of char array not showing? The location of the pointer is passed to a function.
char plaintext[] = {
0xCD, 0x76, 0x43, 0xF0,
0x72, 0xA4, 0xA0, 0x82,
}
Given
void displayArray(char** plaintext, int size) {
// int newSize = sizeof(**plaintext);
int i;
for(i=0; i < size; ++i) {
printf("%02X ", (0xff & *plaintext[i]));
if (((i+1)% 8) == 0) // as index starts from 0, (i+1)
printf("\n");
}
}
in main()
char* plaintextCopy;
plaintextCopy = (char*) malloc(numberOfItems*sizeof(char));
memcpy(plaintextCopy, plaintext, numberOfItems);
displayArray(&plaintextCopy, numberOfItems);
numberOfItems? I don't thinkmemcpy()and yourdisplayArray()use the same definition.int numberOfItems = sizeof(plaintext);printf("Number of items: %d \n", numberOfItems);