1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include <windows.h> #include <stdio.h> struct FileInfo { TCHAR *buf; TCHAR *buf2; int iSize; }; void main() { int iSize = 1024*1024*1024; FileInfo *pfi = NULL; pfi = new FileInfo; if(pfi != NULL) { pfi->buf = (char*)malloc(iSize); pfi->buf2 = (char*)malloc(260); strcpy(pfi->buf,"123"); strcpy(pfi->buf2,"456"); } pfi->iSize = iSize; printf("%s\n",pfi->buf); printf("%s\n",pfi->buf2); printf("%d\n",pfi->iSize); } |
转载请注明:exchen's blog » 动态分配结构字符串