This is a question about language pointer!!

Asked 2 years ago, Updated 2 years ago, 50 views

There was no error when I touched the pointer like that, but sometimes there is an error like that.

No matter how much I think about it, I don't think there will be any errors, but it's not like that every time, but it's like that from time to time, so there's a reason, No matter how much I think about it.

I would appreciate it if you could point out if there is anything I don't know about the pointer or if there is a mistake.

c pointer

2022-09-20 16:55

1 Answers

L->header->next = L->trailer;

A BAD_ACCESS error occurred here. You want to access address=0x8, but an absolute address like 0x8 is a memory address that should not be accessed.

Consider which of the above codes is 0x8.

One of these three has the address 0x8, and L is the & test. Since test is a variable caught in the stack, &test (= L) should have the legitimate address of the stack.

L->header and L->trailer are legitimate addresses. It should be pointing somewhere on the stack.

If you look at number 2, it's L->header->next, where L->header is the Node* type, which is a pointer and should be some memory address value. However, when declaring test, there is no designation for the header or trailer node in it. It depends on the release, debugger mode build, but I think the test was initialized because the content was filled with 0. So, the L->header has an address value of 0. That is, Nulpointer. Since L->header is 0, the address of L->header->next is the offset to the next member of the node. This is a situation where offset is 0x8.

OK


2022-09-20 16:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.