How to assign a value to a pointer in the C language?

In C language, you can assign the value of a pointer variable (i.e. the memory address it points to) to another pointer variable using the assignment operator (=). For example:

int num = 10;
int *ptr1 = #  // 将指向num的地址赋给ptr1
int *ptr2 = ptr1;  // 将ptr1的值(即指向num的地址)赋给ptr2

In the example above, both ptr1 and ptr2 point to the memory address where num is stored.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds