Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Structure

Status
Not open for further replies.

mostar

Technical User
Mar 24, 2003
1
BA
I need help about structure.I neet to know can in structure be called another structure and how?
Thank you
 
struct FRED
{
int one;
int two;
};

struct TOM
{
int three;
struct FRED fredStruct;
}


Is this what you were looking for..???
Cheers
KK
 
Another way that may be what you are looking for:

struct mydatatype {
int y, x, r;
char *varstring;
struct mydatatype *(pnextcall)(struct mydatatype *pprev);
};

Where the pointer to the function pnextcall creates
the list linkage and returns the next initialized list
element.
 
//The data structure.
//*****************************
struct data
{
char field1 [256];
char field2 [256];
char field3 [256];

struct data *nextptr;
struct txtline *firstline1;
};
//these are aliases for the structure.
typedef struct data DATA;
typedef DATA *DATAPTR;
//*****************************

//*****************************
struct txtline
{
char textline [256];
struct txtline *nextptr;
};
//these are aliases for the buffer structure.
typedef struct txtline TXT;
typedef TXT *TXTPTR;
//*****************************

in this example I have two structures in the data structure.
the first is a structure of the same type. Look into linked lists. the second structure is of the second type.
this is a linked list inside of the first linked list.

tomcruz.net
 
Hi,
The example butthead gave is the data structure called "hash table". Each node of the link list is an entry into hash table and is the head node for another list. So, if you imagine, it would be a table with list hanging out at every node of table.

regards,
Mahesh
 
Cooool!!!!!!!!!!!!

I didn'nt even know I was doing hash tables.

I guessd I'm smarter than I think. ;-)

tomcruz.net
 
Hey,
The only difference between actual hash table implementation and this is of hash key. Hash key is index (similar to index in array) which can be either some unique values or values generated using hash function. And, the value linked to that index can be either some integer, structure, or head node of link list.

So, I wanted to give just a rough picture of hash table to those, who are new to data structure. Hope, I din't confused you guys :)

regards,
Mahesh
 
despite all this I hope it answered the poor guy's question.

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top