64,637
社区成员
发帖
与我相关
我的任务
分享
#include <string.h>
#include <iostream>
using namespace std;
struct dump
{
int id;
char p[1];
};
int main()
{
string ss = "0123456789abcd";
int size = sizeof(dump);
dump* pdump = ( dump*)malloc(size);//+ strlen("0123456789abcd")+1);
strcpy(pdump->p ,ss.c_str());
cout<<pdump->p<<endl;
int b=9;
cout<<b<<endl;
}
struct mumble
{
char pc[1];
};
struct mumble* pmumble = (struct mumble* ) malloc (sizeof(struct mumble ) + strlen(string) + 1);
strcpy(pmumble->pc, string ) ;