Structures unions and enumeration is used to create a new datatyppe that holds all kinds of datatype that is it includesn a datatype that can hold int, float, char, array inside a user ndefined datatype.
Pradeep Bhupathi said:
(Wed, Aug 25, 2010 02:42:30 PM)
Array, pointer, structure, union, enum - These all are user defind data types in c language.
Lokeswari said:
(Sun, Dec 5, 2010 12:13:57 PM)
What is pointer?
Yamuna said:
(Thu, Dec 9, 2010 08:11:33 AM)
Since Structure,Union,Enum are all User defined data types so user can use new values...thus logic is simple.. :-)
Varun said:
(Fri, Jan 7, 2011 02:06:36 PM)
But what is the difference?
Lipsa said:
(Tue, Feb 1, 2011 10:05:01 AM)
I agree with the runa and the main difference is the structure allocate different memory location with the data types but union allocate one large memory location for their members.
Surya said:
(Thu, Mar 10, 2011 12:58:25 AM)
These are used to create a new data type that holds all data types.
Nagarjun said:
(Thu, Mar 10, 2011 05:22:36 AM)
S.I agree vtt the Lips .but Enumrated gives the different states of a variable
example;
Enum person
{
male,fmale;
}
where the person having 2 states male r female;
Question is the similarity between a structure, union and enumeration. I think These all are the user defined data type. That holds various types of other data types.
But enum will store's integer constants only. How it can store all types of datatypes.
Prabhu said:
(Sat, Sep 24, 2011 03:31:26 PM)
What is union ?
Raju Naidu said:
(Fri, Oct 28, 2011 12:41:36 PM)
Structure,union,enum all are userdefined datatypes.
Let we take one senario for structure.
Suppose in my programm i've to take the 100 variables. If you want to define many variables of different datatype, instead of declaring all those variables individually just go through sructure.Just define the one structure and take all those variables into that structure.
Then if you want to access any variable, just take the structname and dot operator and variable name.then we can access those variables.
union also used for storing the different datatypes variables. But there is small difference between structure and union.i.e
In structures we can acess all those variables at a time because of they are sharing different memory locations.
But in unions whatever we declare in the union those all are sharing same memory that's why at a time we can access only one variable. enum also used for storing user defined variable
Ex: enum { married,divorced,unmarred}
By defaultley married is indexed by o,divorced is 1, unmarried is 2.
If you want to change this order you can change by using married=10 then divorced = 11, unmarried = 12.
Saravanan said:
(Sun, Dec 4, 2011 11:37:58 PM)
Nice Explanation raju.......
Vinaysan said:
(Thu, Dec 8, 2011 11:27:43 PM)
I agree with runs. He/she said very nice defnition. And one more is the main difference between structure and union is
Structures allocates diffrent memory locations.
Union allocates large memory.
Jithin James said:
(Mon, Dec 19, 2011 11:47:46 AM)
Can anyone explain more about Enum....plz
Reshmi Singh said:
(Thu, Dec 22, 2011 04:44:01 PM)
Nice explanation raju. Enum is basically used for storing different datatypes variables. It is follow indexes like{0, 1, 2, . }.
Rohit8421 said:
(Fri, Jan 13, 2012 10:19:23 PM)
I'm agree that structures and union are use to define new data type , but how enumeration is use to define new data type. it just internally store an integer value.