
- C - Home
- C - Overview
- C - Features
- C - History
- C - Standards
- C - Environment Setup
- C - Program Structure
- C - Hello World
- C - Compilation Process
- C - Comments
- C - Basic Syntax
- C - User Input
- C - printf Function
- C - Format Specifiers
- Lexical Elements in C
- C - Tokens
- C - Keywords
- C - Identifiers
- Variables and Constants
- C - Variables
- C - Constants
- C - Const Qualifier
- C - Linkage
- Data Types and Type Conversions
- C - Data Types
- C - Literals
- C - Escape Sequences
- C - Booleans
- C - Integer Promotions
- C - Character Arithmetic
- C - Type Conversion
- C - Type Casting
- Operators in C
- C - Operators
- C - Arithmetic Operators
- C - Unary Operators
- C - Relational Operators
- C - Logical Operators
- C - Bitwise Operators
- C - Assignment Operators
- C - Increment and Decrement Operators
- C - Ternary Operator
- C - sizeof Operator
- C - Operator Precedence
- C - Miscellaneous Operators
- Decision Making & Control Statements
- C - Decision Making
- C - if Statement
- C - if...else Statement
- C - if...else if Ladder
- C - Nested if Statements
- C - Switch Statement
- C - Nested Switch Statements
- C - Switch Case Using Range
- Loops in C
- C - Loops
- C - For Loop
- C - While Loop
- C - Do...while Loop
- C - For Loop vs While Loop
- C - Nested Loop
- C - Infinite Loop
- C - Break Statement
- C - Continue Statement
- C - Goto Statement
- Functions in C
- C - Functions
- C - Function Prototype
- C - Main Function
- C - Function call by Value
- C - Function call by reference
- C - Nested Functions
- C - Variadic Functions
- C - User-Defined Functions
- C - Callback Function
- C - Return Statement
- C - Recursion
- C - Predefined Identifier __func__
- Scope Rules in C
- C - Scope Rules
- C - Static Variables
- C - Global Variables
- Arrays in C
- C - Arrays
- C - Properties of Array
- C - Multi-Dimensional Arrays
- C - Passing Arrays to Function
- C - Return Array from Function
- C - Variable Length Arrays
- C - Dynamic Arrays
- Strings in C
- C - Strings
- C - Array of Strings
- C - Character Arrays
- C - Special Characters
- Pointers in C
- C - Pointers
- C - Initialization of Pointer Arrays
- C - Applications of Pointers
- C - Dereference Pointer
- C - NULL Pointer
- C - void Pointer
- C - Const Pointers & Pointer to Const
- C - Dangling Pointers
- C - Pointer Arithmetics
- C - Pointers and Arrays
- C - Pointer vs Array
- C - Pointer to an Array
- C - Array of Pointers
- C - Pointers vs. Multi-dimensional Arrays
- C - Pointer to Pointer
- C - Chain of Pointers
- C - Character Pointers and Functions
- C - Passing Pointers to Functions
- C - Return Pointer from Functions
- C - Function Pointers
- C - Array of Function Pointers
- C - Pointers to Structures
- C - Near, Far and Huge Pointers
- C - Restrict Keyword
- User-Defined Data Types
- C - Structures
- C - Structures and Functions
- C - Arrays of Structures
- C - Self-Referential Structures
- C - Dot (.) Operator
- C - Lookup Tables
- C - Enumeration (or enum)
- C - Structure Padding and Packing
- C - Nested Structures
- C - Anonymous Structure and Union
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Flexible Array Members in Structures
- C - Structures vs Unions
- Memory Management in C
- C - Memory Layout
- C - Memory Management
- C - Memory Address
- C - Storage Classes
- C - Dynamic Array Resizing
- C - Memory Leaks
- File Handling in C
- C - File Handling
- C - Input & Output
- C - File Operations
- C - Formatted Output
- C - getc, getchar, getch, getche
- Preprocessors in C
- C - Preprocessors
- C - Pragmas
- C - Macros
- C - Working of Preprocessor
- C - Preprocessor Operators
- C - Header Files
- C - Custom Header Files
- Miscellaneous Topics
- C - Error Handling
- C - Variable Arguments
- C - Command Execution
- C - Math Functions
- C - Static Keyword
- C - Random Number Generation
- C - Command Line Arguments
- C Programming Resources
- C - Questions & Answers
- C - Quick Guide
- C - Cheat Sheet
- C - Useful Resources
- C - Discussion
- C - Online Compiler
Special Characters in C
The C language identifies a character set that comprises English alphabets upper and lowercase (A to Z as well as "a" to "z"), digits 0 to 9, and certain other symbols called "special characters" with a certain meaning attached to them.
While many of the characters in the special symbol category are defined as operators, certain combinations of characters also have a special meaning attached to them. For example, "\n" is known as the newline character. Such combinations are called escape sequences.
In C language, quotation marks too have a special meaning. Double quotes are used for strings, while characters are enclosed inside single quotes. Read this chapter to learn more about the other special characters used in C programs.
Parentheses ()
Parentheses are especially used to group one or more operands in an expression and control the order of operations in a statement.
A part of the expression embedded inside parentheses has a higher order of precedence.
Example
int a = 2, b = 3, c = 4; int d = (a + b) * c;
Braces { }
Braces are especially used to define blocks of code, such as function bodies and loops. They are also used to initialize arrays and struct variables.
Examples
Braces in function definition −
int add(int a, int b){ int sum = a + b; return sum; }
Braces in array initialization −
int arr[5] = {1, 2, 3, 4, 5};
Braces in struct variable −
struct book { char title[10]; double price; int pages; }; struct book b1; struct book b1 = {"Learn C", 675.50, 325};
Square Brackets [ ]
Square brackets are used to declare arrays and access elements of an array with the subscript index.
Example
For example, to define an array of integers and access its third element, you would use square brackets −
int arr[5] = {1, 2, 3, 4, 5}; int third = arr[2];
Asterisk (*)
Apart from its use as a multiplication operator, the asterisk symbol (*) is also used to declare a pointer variable and dereference it to obtain the value of the target variable.
Example
For example, to define a pointer to an integer and access the value it points to, you would use an asterisk −
int num = 10; int *ptr = # printf("*d", *ptr);
Ampersand (&)
The ampersand (&) symbol is used as the address-of operator. It returns the address of a variable.
Example
For example, to get the address of an integer variable, you would use an ampersand −
int num = 10; int *ptr = #
Comma (,)
The comma is used as a separator between a statement or a function call.
Example
int a = 1, b = 2, c = 3;
Semicolon (;)
As a primary syntax rule in C, the semicolon indicates the end of a statement in a C program.
Example
printf("Hello, world!");
Dot (.)
The dot symbol (.) is used to access the members of a structure or a union.
Example
struct book b1 = {"Learn C", 675.50, 325}; printf("Title: %s\n", b1.title); printf("Price: %lf\n", b1.price); printf("No of Pages: %d\n", b1.pages);
Arrow ()
The arrow symbol () is used to access the members of a structure or a union through a pointer.
Example
struct book b1 = {"Learn C", 675.50, 325}; struct book *strptr; strptr = &b1; printf("Title: %s\n", strptr->title); printf("Price: %lf\n", strptr->price); printf("No of Pages: %d\n", strptr->pages);