函数指针 往指定内存中写数据

来源:互联网 发布:c语言入门推荐用书 编辑:程序博客网 时间:2024/05/18 02:57

1 函数指针的定义和调用
 简单的函数指针 
 void (*fun)(void)
再定义个函数实体
void hello(void)
{
 printf("hello world");
}
调用时  fun = hello;
(*fun)();
当某个地址就是函数的入口地址
也可以这样用
fun = (void (*)(void))0x37010000;
fun();( fun 和 (*fun)都指函数的地址 ,加上()指调用;
3往内存地址中写数据
#define UTXH0 (*(voaltile unsigned int *)0x12345678)
UTXH0 = 0x123;(写数据)

也可以
int *p = (volatile int *)0x12345678;
*p = 0x123;

原创粉丝点击