且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

共享库和应用程序之间传输数据

更新时间:2022-12-22 12:07:02

由于下用价值,包括指针传递参数,你需要通过的地址指针焦炭** ,一个函数,使函数指针指向不同的地址,并有给调用者可见的那些变化:

As C passes arguments by value, including pointers, you need to pass the address of the pointers, char**, to a function to enable the function to point the pointers to a different address and have those changes visible to the caller:

int genratedCamData(int CAM, char** datafirst , char **datasecond)
{
    *datafirst=getCam1data();
    *datasecond=malloc(100); /* sizeof(char) is guaranteed to be 1. */
}

调用:

char* data1;
char* data2;
genratedCamData(1, &data1 , &data2);