
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
Stringize and Token-pasting operator in C
In this section we will see what are the Stringize operator and Token Pasting operator in C. The Stringize operator is a preprocessor operator. It sends commands to compiler to convert a token into string. We use this operator at the macro definition.
Using stringize operator we can convert some text into string without using any quotes.
Example Code
#include<stdio.h> #define STR_PRINT(x) #x main() { printf(STR_PRINT(This is a string without double quotes)); }
Output
This is a string without double quotes
The Token Pasting operator is a preprocessor operator. It sends commands to compiler to add or concatenate two tokens into one string. We use this operator at the macro definition.
Example Code
#include<stdio.h> #define STR_CONCAT(x, y) x##y main() { printf("%d", STR_CONCAT(20, 50)); }
Output
2050
- Related Articles
- Token Bus and Token Ring
- Difference between Token Bus Network and Token Ring Network
- What is early token release and delayed token release?
- deque::operator= and deque::operator[] in C++ STL
- Difference between "new operator" and "operator new" in C++?
- new and delete operator in C++
- Operator Precedence and Associativity in C
- Token Passing in Bit-Map Protocol
- What is CSRF token in Django?
- What is accounting token?
- Increment ++ and Decrement -- Operator Overloading in C++
- Comma operator in C/C++
- Token Bus (IEEE 802.4) Network
- Unary operator in C++
- Ternary Operator in C#

Advertisements