구조체의 주소를 우리가 지정한 주소로 설정하려고하지만 구조체의 주소를 출력 할 때 주소가 우리와 같은 값이 아닌 것처럼 보입니다 주어진. 라인연결된 목록에서 구조체 가리키는
node *root = (node *)&array;
당신은 "배열"지역 변수의 주소를 취하고에서
/*a struct to keep block information*/
struct header{
int space;
int free; /* 1 = free space and 0 = full*/
struct header *nextHead;
struct header *prevHead;
};
typedef struct header node;
int myinit(int *array, int size){
int newSize = size;
node * nullPointer;
nullPointer = NULL; //make intermediatry node pointer for some bullshit reason
* (array) = newSize; /*store the size of the malloc at the first address*/
printf("Address : %p\n", &array[0]);
array++;
printf("Address after: %p\n", &array[0]);
/*initial block*/
node *root = (node *)&array; /*store the root at the next address available*/
printf("size of struct %lu\n", sizeof(struct header));
printf("%p\n", root);
root->space = newSize;
root->free = 1;
root->nextHead = nullPointer;
root->prevHead = nullPointer;
}
코드가 처음에는 잘 보인다 언뜻보기에 문제가 어디 있습니까? – DarkDust