我使用函数指针遇到了两个不同的代码.
请告诉我哪一个更好?有什么偏好吗?
typedef int myFunction(int a,int b);
extern myFunction *ptfunction;
Run Code Online (Sandbox Code Playgroud)
和
typedef int (*ptfunction)(int a,int b);
Run Code Online (Sandbox Code Playgroud) 我想将存储在结构中的一些数据复制到另一个.下面的代码是否有效?是否推荐?
#define SIZE 100
struct {
int *a;
int *b;
} Test;
Test t1;
t1.a = malloc(SIZE);
t1.b = malloc(SIZE);
Test t2;
memcpy(t2,t1,sizeof(Test));
Run Code Online (Sandbox Code Playgroud)