I'm trying to store the row address of an array. It seems as though the addresses are passed correctly but they don't seem to refer to the values stored in the array.
I want to save the addresses so I can then use them in a Python application.
#include <stdio.h>
#include "func.h"
int main(int argc, const char * argv[]) {
uint64_t pkt[3];
func(pkt);
printf ("The address in main is %p\n", pkt[0]);
printf ("The address in main is %p\n", pkt[1]);
printf ("The address in main is %p\n", pkt[2]);
uint8_t *ptr0 = (uint8_t*)pkt[0];
printf ("The address in main is %p\n", ptr0);
printf("%d\n", ptr0[0]);
printf("%d\n", ptr0[1]);
printf("%d\n", ptr0[2]);
uint8_t *ptr1 = (uint8_t*)pkt[1];
printf ("The address in main is %p\n", ptr1);
printf("%d\n", ptr1[0]);
printf("%d\n", ptr1[1]);
printf("%d\n", ptr1[2]);
uint8_t *ptr2 = (uint8_t*)pkt[2];
printf ("The address in main is %p\n", ptr2);
printf("%d\n", ptr2[0]);
printf("%d\n", ptr2[1]);
printf("%d\n", ptr2[2]);
return 0;
}
#include "func.h"
void func(uint64_t* pkt)
{
uint8_t matrix[3][3] = { {3 , 7 , 4} ,
{1, 2 , 8} ,
{8 , 3, 2} } ;
int i = 0;
for (i = 0; i < 3; i++)
{
pkt[i] = (uintptr_t)&matrix[i];
printf("The address is %p\n", &matrix[i]);
printf("The address is %p\n", pkt[i]);
}
}