Typedef

typedef is used to redefine the existing data type names. Basically, it is used to provide new names to the existing data types. The “typedef” keyword is used for this purpose;

Syntax

typedef existing_name alias_name;

Example

C




// C Code to implement Typedef
#include <stdio.h>
  
typedef char Company;
  
int main()
{
    Company* name = "w3wiki";
    printf("Best Tutorials on: %s \n", name);
    return 0;
}


Output

Best Tutorials on: w3wiki 


User-Defined Data Types In C

Data Types are the types of data that can be stored in memory using a programming language. Basically, data types are used to indicate the type of data that a variable can store. These data types require different amounts of memory and there are particular operations that can be performed on them. These data types can be broadly classified into three types:

  1. Primitive Data Types
  2. Derived Types
  3. User Defined Data Types

In this article, will discuss the User-Defined Data Type.

Similar Reads

What is a user-defined Datatype in C?

The data types defined by the user themself are referred to as user-defined data types. These data types are derived from the existing datatypes....

Types of User-Defined DataTypes

There are 4 types of user-defined data types in C. They are...

1. Structure

As we know, C doesn’t have built-in object-oriented features like C++ but structures can be used to achieve encapsulation to some level. Structures are used to group items of different types into a single type. The “struct” keyword is used to define a structure. The size of the structure is equal to or greater than the total size of all of its members....

2. Union

...

2. Enumeration (enums)

Unions are similar to structures in many ways. What makes a union different is that all the members in the union are stored in the same memory location resulting in only one member containing data at the same time. The size of the union is the size of its largest member. Union is declared using the “union” keyword....

Typedef

...

Contact Us