我想要爲我的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++嗎?選擇適當的語言。 –