欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

传递指针参数(函数内部给指针赋值)示例

程序员文章站 2022-04-16 10:18:17
~~~~ include unsigned char ptr = NULL; unsigned char num = 3; static void fun(unsigned char mem) { mem = # } int main() { fun(&ptr); printf("%d \n ......
#include <stdio.h>

unsigned char *ptr = NULL;
unsigned char num = 3;

static void fun(unsigned char **mem)
{
    *mem = &num;    
} 

int main()
{
    fun(&ptr);
    printf("%d \n", *ptr);
    
    return 0;
}