A
arnuld
I have some basic questions about a C struct. Here is a struct my friend
has created:
struct my_struct
{
char ID[20];
char name[20];
char message[100];
struct a_queue* p;
struct a_singly_linked_list* p2;
struct a_binary_tree* p3;
unsigned long long uc;
int num;
int num_max;
int num_finished;
int num_current;
struct my_struct* next;
}
The structured he created actually had 19 members in total. It looked like
a mess to me, So I thought grouping related members in a new struct will
be a good idea. Hence I modified it to look like this:
struct my_struct_modified
{
struct info* info;
struct ds* ds;
struct nums* nums;
struct my_struct_modified* next;
}
struct info
{
char ID[20];
char name[20];
char message[100];
}
struct ds
{
struct a_queue* p;
struct a_singly_linked_list* p2;
struct a_binary_tree* p3;
unsigned long long uc;
}
struct nums
{
int num;
int num_max;
int num_finished;
int num_current;
}
Before I represent this to my team I want to know if its a good idea. is
it ? Will it be messy in fetching the values of pointers in a struct
inside a struct ?
2nd, increasing the members in a struct (say 19 members) will make the
program run slower as compared to say (10 members) ?
has created:
struct my_struct
{
char ID[20];
char name[20];
char message[100];
struct a_queue* p;
struct a_singly_linked_list* p2;
struct a_binary_tree* p3;
unsigned long long uc;
int num;
int num_max;
int num_finished;
int num_current;
struct my_struct* next;
}
The structured he created actually had 19 members in total. It looked like
a mess to me, So I thought grouping related members in a new struct will
be a good idea. Hence I modified it to look like this:
struct my_struct_modified
{
struct info* info;
struct ds* ds;
struct nums* nums;
struct my_struct_modified* next;
}
struct info
{
char ID[20];
char name[20];
char message[100];
}
struct ds
{
struct a_queue* p;
struct a_singly_linked_list* p2;
struct a_binary_tree* p3;
unsigned long long uc;
}
struct nums
{
int num;
int num_max;
int num_finished;
int num_current;
}
Before I represent this to my team I want to know if its a good idea. is
it ? Will it be messy in fetching the values of pointers in a struct
inside a struct ?
2nd, increasing the members in a struct (say 19 members) will make the
program run slower as compared to say (10 members) ?