struct NUMBERS
{
char name[MAXCHARS];
struct NUMBERS *value;
};
i am new to programming ...can anyone explain this for me ?
struct NUMBERS
{
char name[MAXCHARS];
struct NUMBERS *value;
};
i am new to programming ...can anyone explain this for me ?
This is defining a custom data type; a structure of type NUMBERS.
This newly defined data type contains two sub-objects. This first of these sub-objects is an array of chars, labelled "name". The array is MAXCHARS long.
The second sub-object is a pointer named value. It is a pointer to objects of type NUMBERS, which is a struct.
This does not actually create any new objects; it just defines what one of these new objects will look like when you do actually create one. You would then create one as follows:
struct NUMBERS anInstance;
and then access the internal objects like this:
anInstance.name[0] = 'A';for example.
Ummmm this is called self refrential structure which is basically nothing but referring to a structure of its own type.
struct node {
int data;
struct node *next;
};
In the code above , a pointer is used . Pointer is used for storing either a valid address or NULL.
here next is a pointer which will store some address which is of struct node type .
for eg.
in the code:-
int a=5;
int *b;
b=&a;
b is a pointer which will store the address of any integer data.
similarly with *next , it will store the adress of that element whose memory block have an integer space and a space for storing of address of struct node type.
Ummmm...
There's no need to type everything you say. You can leave out the "Ummmm" at the beginning.
Moschops
Requesting not to quote on the things which are out of topic and not related to the subject.
If I am mistaking and lacking in my concepts then please help me and others to advance our concepts so that I can improve myself and any other people who come here through google search can see only the things related to topic not these thing which can degrade the reputation of daniweb.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.