When I allocate memory with malloc()
, are the addresses equal to a vector? Or are they scattered in the memory of the PC?
I want to create a list of structs
, to do this, I have to have several structs
in case, can I do this just by allocating memory with ( malloc()
) or is there another way to do it? p>
Example:
int n=7,cout;
Node *lista; <- Essa lista Node vamos supor que eu tenha criado antes do main.
for(cout=1;cout<=n;cout++){
lista = (Node*)malloc(sizeof(Node)*n);
}
I did this to create 7 nodes.
When doing this, am I actually using the list concepts? And if I want to bind my pointer that is in struct
to another node, how do I identify the other node since all are of type Node
and have the same name? And what does malloc()
differ from a vector? But I ask this not in the sense of a static being and another dynamic, but in the positions of memory.