#include <stdio.h>
#include<unistd.h>
int main(int argc, const char* argv[])
{
int Ret;
char buf[] = "123123123123121231232122321312";
char * pread = NULL;
char * pwrite = buf;
int pipetest[2];
if(pipe(pipetest) < 0)
{
printf(" face lib to vo pipe creat error!");
}
else
{
printf(" face lib to vo pipe creat success!\n");
}
printf("%s \n", buf);
/* 管道 发送/接收 指针必须是 &指针 的格式 */
/* 接收的正常使用指针即可 */
Ret = write(pipetest[1], &pwrite, sizeof(pwrite));
if(Ret >= 0)
{
printf("%s sizeof(pwrite) %lu\n", pwrite, sizeof(pwrite));
}
Ret = read (pipetest[0], &pread, sizeof(pread));
if(Ret >= 0)
{
printf("%s sizeof(pread) %lu\n", pread, sizeof(pread));
}
close(pipetest[0]);
close(pipetest[1]);
}
另外:
A* -> void* -> int -> A*
A* tmp类型通过传参 转化为 void* tmp, 然后转化成int a, 然后赋值转化成A* aa = a;