Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 3 min read

Support

C was designed in English and assumes the common ASCII character set made for English, which includes such characters as {, }, , ], and so on. Some other character sets (like [EBCDIC on mainframes), however, do not have these or other characters which are required by C. Since even the simplest C program uses curly braces to define main(), developing in C would be impossible on these systems.

To solve this problem, trigraph sequences can be substituted for the symbols.[1] They will work in any situation; the first translation phase of compilation replaces the trigraph sequences with their corresponding single-character equivalents.[2]

Trigraphs were later supplemented with digraphs,[3] but neither were in widespread use except in mainframe systems. Trigraphs have been removed from C in version C23.[4] However, they are described here as they may appear in some legacy systems' codebases.

Trigraphs

The following trigraph sequences exist, and no other. Each question mark ? that does not begin one of the trigraph sequences listed is not changed.

SequenceReplacement
??=#
??([
??/\
??)]
??'^
??<{
??!|
??>}
??-~

The effect of this is that source code such as

??=include <stdio.h>

int main(int argc, char **argv) ??<
char message??(20??) = "??-??-Hello, world.??-??-";
printf("%s??/n", message);
??>

will, after trigraphs are replaced, be the equivalent of

#include

int main(int argc, char **argv) {
char message[20] = "Hello, world.";
printf("%s\n", message);
}

Should the programmer want a trigraph not to be replaced, within strings and character constants (which is the only place they would need replacing and it would change things), the programmer can simply escape the second question mark; e.g.

printf ("Two question marks in a row: ??!\n");

MSVC and GCC do not process trigraphs by default, needing the /Zc:trigraphs or -trigraphs (respectively) flag to be passed on the command line to the compiler.[5][6] Clang processes them by default unless the C standard is set to a GNU mode.[7]

Digraphs

Digraphs are equivalent to the following tokens except for their spelling:

DigraphEquivalent
<:[
:>]
<%{
%>}
%:#
%:%:##

In other words, they behave differently when stringized as part of a macro replacement, but are otherwise equivalent.

iso646.h

Header iso646.h focuses only on solving the symbol problem for operators, but takes a different approach of defining keyword-like macros to stand in for them. It is named after the ISO/IEC 646 character encoding standard, which has some variants that do not have these symbols; some variants also must rely on trigraphs or digraphs.

Macros

The iso646.h header defines the following 11 macros as stated below:

MacroDefined as
and&&
and_eq&=
bitand&
bitor|
compl~
not!
not_eq!=
or||
or_eq|=
xor^
xor_eq^=

References

Where this page came from

This page was imported from Wikibooks. From “C programming” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

C programming

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in C programming

CC BY-SA 4.0
This is a basic introduction to good coding style in the C Programming Language. It is designed to provide information on how to effectively use indentation, comments, and other elements that will make your C code more readable. It is not a tutorial on actual C programming. As a beginning programmer
CC BY-SA 4.0
- Only the underscore can be used. - for example, **#nm*rt** is not allowed because # and * are not the valid characters for the name of a variable. #include #include main() { int a, b, c, max; #ifdef __WIN32 system("cls"); // for Windows #else system("clear"); // for Unix and Linux #endif printf("\
CC BY-SA 4.0
[C]( is the most commonly used programming language for writing [operating systems]( The first operating system written in C was [Unix]( Later operating systems like [GNU/Linux]( were all written in C. Not only is C the language of operating systems, but it is also the precursor and inspiration for
CC BY-SA 4.0
The Algorithmic Language ([Algol 58]( was derived from Fortran in 1958 and evolved into [Algol 60]( in 1960. The [Combined Programming Language (CPL)]( was then created out of Algol 60 in 1963. In 1967, it evolved into [Basic CPL]( (BCPL), which was the basis for [B]( which was created in 1971, and
CC BY-SA 4.0
It's also assumed you have some experience interacting with your operating system through a terminal window using its **command line interface.** If you aren't sure what this means, consider seeking out a tutorial for your chosen platform that can get you comfortable with getting around your compute
CC BY-SA 4.0
Therefore, you can use Dev C++ for C development. However, Dev C++ is not the compiler. It is designed to use the [MinGW]( or [Cygwin]( versions of [GCC]( - both of which can be obtained as part of the Dev C++ package, although they are completely different projects. Dev C++ simply provides an edito