- C Programming Tutorial
- C - Home
- Basics of C
- C - Overview
- C - Features
- C - History
- C - Environment Setup
- C - Program Structure
- C - Hello World
- C - Compilation Process
- C - Comments
- C - Tokens
- C - Keywords
- C - Identifiers
- C - User Input
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Integer Promotions
- C - Type Conversion
- C - Type Casting
- C - Booleans
- Constants and Literals in C
- C - Constants
- C - Literals
- C - Escape sequences
- C - Format Specifiers
- Operators in C
- C - Operators
- C - Arithmetic Operators
- C - Relational Operators
- C - Logical Operators
- C - Bitwise Operators
- C - Assignment Operators
- C - Unary Operators
- C - Increment and Decrement Operators
- C - Ternary Operator
- C - sizeof Operator
- C - Operator Precedence
- C - Misc Operators
- Decision Making in C
- C - Decision Making
- C - if statement
- C - if...else statement
- C - nested if statements
- C - switch statement
- C - nested switch statements
- Loops in C
- C - Loops
- C - While loop
- C - For loop
- C - Do...while loop
- C - Nested loop
- C - Infinite loop
- C - Break Statement
- C - Continue Statement
- C - goto Statement
- Functions in C
- C - Functions
- 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
- 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
- Pointers in C
- C - Pointers
- C - Pointers and Arrays
- C - Applications of Pointers
- C - Pointer Arithmetics
- C - Array of Pointers
- C - Pointer to Pointer
- C - Passing Pointers to Functions
- C - Return Pointer from Functions
- C - Function Pointers
- C - Pointer to an Array
- C - Pointers to Structures
- C - Chain of Pointers
- C - Pointer vs Array
- C - Character Pointers and Functions
- C - NULL Pointer
- C - void Pointer
- C - Dangling Pointers
- C - Dereference Pointer
- C - Near, Far and Huge Pointers
- C - Initialization of Pointer Arrays
- C - Pointers vs. Multi-dimensional Arrays
- Strings in C
- C - Strings
- C - Array of Strings
- C - Special Characters
- C Structures and Unions
- C - Structures
- C - Structures and Functions
- C - Arrays of Structures
- C - Self-Referential Structures
- C - Lookup Tables
- C - Dot (.) Operator
- C - Enumeration (or enum)
- C - Structure Padding and Packing
- C - Nested Structures
- C - Anonymous Structure and Union
- C - Unions
- C - Bit Fields
- C - Typedef
- File Handling in C
- C - Input & Output
- C - File I/O (File Handling)
- C Preprocessors
- C - Preprocessors
- C - Pragmas
- C - Preprocessor Operators
- C - Macros
- C - Header Files
- Memory Management in C
- C - Memory Management
- C - Memory Address
- C - Storage Classes
- 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
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);