eerpinisatish wrote:
> hi all,
> i have a small doubt, how are variable type like int , or float
> actually defined in C, like if i want to define a new variable type ,
> which is say completely new, then how do i do it and then use it again
> and again in my programs ??, is it something like the library
> functions , or is there a different method ??
>
Types in C are defined in the compiler's source code logic.
To define a new type of your own, you can use 'typedef'.
eg. define your new type as follows;
typedef int Age;
and use your new type, as often as you like, as follows:
Age ageOfA = 10;
Age ageOfB = 20;
Since the basic types like int, float etc are defined statically in the
source code,
you will have to create your types based on them.
A better example is:
typedef struct _studentRecord {
char name[20];
int age;
} studentRecord;
studentRecord recordForStudentA = {"satish", 10};
- Namita