How to Make Standard Types?

Standard types are the basic data types that are available in C programming language. They are defined in the <stdio.h> header file. The standard types are:

  • int: This type is used to store integer values.
  • char: This type is used to store character values.
  • float: This type is used to store floating-point values.
  • double: This type is used to store double precision floating-point values.

You cannot make your own standard types in C programming language. However, you can create your own data types by using structures and unions.

Structures are used to group together related data items into a single unit. Unions are used to store different data types in the same memory location.

Here is an example of how to create a structure to store the name and age of a person:

struct person {
  char *name;
  int age;
};

This structure can be used to store the name and age of a person. The name member is a pointer to a character string, and the age member is an integer.

Here is an example of how to create a union to store a character, an integer, and a floating-point number:

union data {
  char c;
  int i;
  float f;
};

This union can be used to store a character, an integer, and a floating-point number. The c member is a character, the i member is an integer, and the f member is a floating-point number.

You can use structures and unions to create your own data types that are more appropriate for your needs. This can make your code more readable and maintainable.

Leave a Reply

Your email address will not be published. Required fields are marked *