I have a small problem with memory allocation.
typedef struct
{
int a;
int *b;
}Node;
class B
{
int label;
Node n[10];
}
....
void B::somefunction(int user)
{
.....
n.b = (int *)malloc(sizeof(int)*nuser)
.....
}
I want be able to dynamically declare Node n[10]. What I mean it that I will not know in advance if n[10] is enough or if I require more. I tried a couple of ways of allocating memory with no success.
Any help will be appreciated.
rsshetty.
It's always in the details.
typedef struct
{
int a;
int *b;
}Node;
class B
{
int label;
Node n[10];
}
....
void B::somefunction(int user)
{
.....
n.b = (int *)malloc(sizeof(int)*nuser)
.....
}
I want be able to dynamically declare Node n[10]. What I mean it that I will not know in advance if n[10] is enough or if I require more. I tried a couple of ways of allocating memory with no success.
Any help will be appreciated.
rsshetty.
It's always in the details.