antiantantiant.blog.chinaunix.net
antiant
全部博文(32)
线程间通信(9)
进程间通信(0)
网络通信(1)
2010年(32)
大鬼不动
zzbok
36853
分类: WINDOWS
2010-07-22 22:54:36
#include <stdio.h> #include <memory.h> #include <string.h> #define NODEINFOBUF 32 typedef struct tagNodeInfo { char a; short b; int c; char *d; char *e; }NODEINFO, *PNODEINFO; int main(int argc, char* argv[]) { NODEINFO *node = (PNODEINFO)new char[NODEINFOBUF]; if (NULL == node) return -1; memset(node, 0, NODEINFOBUF); node->a = 10; node->b = 20; node->c = 30; char *pBuf = (char*)&node->d; // 指针的指针强转成char类型指针 strcpy(pBuf, "ddddd"); pBuf+=(strlen(pBuf)+sizeof(char)); // 结尾标志符 strcpy(pBuf, "eeeee"); delete[] (char*)node; node = NULL; return 0; }
上一篇:指针数组和数组指针
下一篇:Ubuntu下获取IP地址, 子网掩码, 网关, DNS
登录 注册