我想要为我的noeud分配内存(成功)动态内存分配的C++字符串
NOEUD* CreerNoeud(DF x)
{
NOEUD* pn = (NOEUD*)malloc(sizeof(NOEUD));
if (pn == NULL)
{
printf("probleme allocation, on arrete \n");
}
else
{
// Allocation valide
pn->data= x;
pn->data = x;
pn->suivant = NULL;
}
return pn;
}
,但我有我的结构串
“错误读取字符的数据存储问题。 “
typedef struct DF
{
std::string Lside;
std::string Rside;
}DF;
typedef struct NOEUD
{
DF data;
struct NOEUD* suivant;
}NOEUD;
'pn-> data = x;'next line'#pn-> data = x;'你有快门吗? –
当你使用'std :: string'时,为什么你把它标记为'c'? –
你想要C或C++吗?选择适当的语言。 –