strange linked list problem
Normaly I would post this in the C++ board, but I think the problem is windows related.
I have class witch can add nodes and brows through a linked list.
the function that adds the node looks like this:
some words are dutch, I'll translate to clearefy (sp?)
bool CMP3LIST::AddToList(int length,char title[MAX_PATH],char filepath[MAX_PATH])
firsttime = false;
so when I want to add a nod, I call the function like this:
lpofn is of the type OPENFILENAME
and lpofn.lpstrFile gets filled in by the GetOpenFileName function from the WIN32 API
but after the malloc, the value of lpofn.lpstrFile changes. I don't see how this is possible? does windows override a piece of memory that holds the OPENFILENAME data? and strangly, there is just one letter that changes in the filename
example: c:\My Documents\... changes to c:\My DoTuments\...
How is this possible????
is there some underlying memory bug somewhere that I'm not aware of.
I corrected the problem by adding a strcpy before the addtolist function, like this:
it works, but it doesn't give me an explination why this happens.
and the lpofn.lpstrFile still changes and it isn't even part of the class it is a global variable.
anyone has an idea about this, why this happens?
BTW, if my function to add nodes contains bugs, or there are better ways to do it, let my know ;)