Trigraphs in C++ with Examples
Last Updated :
17 Jul, 2020
In C++, a trigraph is a three-character sequence that represents a single character. It means that trigraph sequences are the set of three characters starting from double question marks (??). These characters are constructed using a sequence of 3 characters called trigraphs and these set of the characters are replaces by a single character.
S.No. |
Trigraph |
Equivalent |
1. |
??= |
# |
2. |
??/ |
\ |
3. |
??’ |
^ |
4. |
??( |
[ |
5. |
??) |
] |
6. |
??! |
| |
7. |
??< |
{ |
8. |
??> |
} |
9. |
??- |
~ |
Syntax:
??=define
Becomes,
#define
Below is the basic implementation example of the Trigraphs sequences:
C++
# include <iostream>
using namespace std;
??=define MSG "GeeksforGeeks"
??=define Program "C++"
int main()
??<
cout << "My message to " << MSG << endl;
cout << "My program is " << Program;
return 0;
??>
|
Output:
My message to GeeksforGeeks
My program is C++
Below is another example of the Trigraph sequences:
C++
# include <iostream>
using namespace std;
??=define Name "Kalpana"
??=define Age "23"
??=define Qualification "B.tech"
??=define From "Delhi"
int main()
??<
cout << "My Name is: " << Name << endl;
cout << "My Age is: " << Age << endl;
cout << "My Qualification is: "
<< Qualification << endl;
cout << "I'm From " << From;
return 0;
??>
|
Output:
My Name is: Kalpana
My Age is: 23
My Qualification is: B.tech
I'm From Delhi
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...