Dynamic memory allocation for structure

Status
Not open for further replies.

Murugesh_89

Full Member level 5
Joined
Nov 23, 2012
Messages
266
Helped
7
Reputation
12
Reaction score
6
Trophy points
1,298
Location
India
Visit site
Activity points
3,267
Hi,
I am having a structure of this type

struct group
{
unsigned int16 group_total_value;
unsigned int8 group_avg_value,group_member;
};

I just want to create groups of nearby values out some 30 values..
ex,
group 0 : 15,11,14,15,13,12,11
group 1 : 27,32,28,29,30
group 2 : 45,46,45,47,48,44,43,44,47,46
group 3 : 66,65,64,63,66,64,63,65

the number of groups may vary(in this ex its 4). So i want to create this structure dynamically.

So how can i do this in C by using dynamic memory allocation..

Thanks,
Murugesh
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…