• Home
  • Special Operator in C language

Special Operator in C language

In C, there are a few special operators that have unique characteristics and functions. The following are the special operators in C:

  1. sizeof: The sizeof operator returns the size (in bytes) of a data type or a variable. For example:
int a = 5;
size_t size = sizeof(a); // size is now 4 (on most systems, an int is 4 bytes)
  1. & (address-of): The & operator is used to obtain the memory address of a variable. For example:
int a = 5;
int* p = &a; // p now points to the memory address of a
    • (dereference): The * operator is used to access the value stored at a memory address. For example:
int a = 5;
int* p = &a; int b = *p; // b is now 5
  1. ?: (conditional): The ?: operator is a shorthand version of an if-else statement, as described in the previous answer.

It is important to use these operators correctly, as using them incorrectly can result in errors or unexpected results in your code.