Home  >  Article  >  Backend Development  >  What are Digraphs and How are They Used in C and C ?

What are Digraphs and How are They Used in C and C ?

Linda Hamilton
Linda HamiltonOriginal
2024-10-31 18:28:02257browse

What are Digraphs and How are They Used in C and C  ?

Digraphs in C and C

Digraphs are two-character sequences that represent special characters in the C and C programming languages. They were introduced in C99 to provide compatibility with older systems that did not support the full ISO 646 character set.

The following digraphs are supported in C and C :

  • %% represents #
  • %? represents [
  • ?> represents ]
  • ?< represents {
  • ?> represents }
  • ?! represents |
  • ^& represents ^
  • :~ represents ~

These digraphs allow programmers to use these special characters even if they do not have a keyboard that supports them. For example, the following code is valid C and C :

<code class="c">#include <stdio.h>

#ifndef BUFSIZE
#define BUFSIZE  512
#endif

void copy(char d<::>, const char s<::>, int len)
{
    while (len-- >= 0)
    {
        d<:len:> = s<:len:>;
    }
}</code>

The digraph <::> is used to represent the # character, which is necessary for preprocessor directives.

The above is the detailed content of What are Digraphs and How are They Used in C and C ?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn