Answer the question
In order to leave comments, you need to log in
Why is there garbage in the variable?
Good afternoon!
There is a structure that stores a couple of lines:
struct KeyValue {
String Key;
String Value;
KeyValue* Next;
};
KeyValue* Last = &Variable;
KeyValue N = KeyValue { Name, Val, nullptr};
Last->Next = &N;
Last = Last->Next;
Answer the question
In order to leave comments, you need to log in
Because the variable N is local, and ceases to exist after the line:
You should do this:
KeyValue* Last = &Variable;
KeyValue* pN = new KeyValue { Name, Val, nullptr};
Last->Next = pN;
Last = Last->Next;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question