Home > Backend Development > C++ > body text

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

Linda Hamilton
Release: 2024-10-31 18:28:02
Original
254 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!