Wednesday, June 20, 2012

trigraphs in c


trigraph" -- C Language" "


trigraph is a set of three characters that represents one character in the C character set. The set of trigraph sequences was defined in the ANSI Standard to allow users to use the full range of C characters, even if their keyboards do not implement the full C character set. Trigraph sequences are also useful with input devices that reserve one or more members of the C character set for internal use; e.g., the Hazeltine family of terminals, which reserves the tilde `~' as its escape character.
Each trigraph sequence is introduced by two question marks. The third character in the sequence indicates which character is being represented. The following table gives the set of trigraph sequences:
      _ T_ r_ i_ g_ r_ a_ p_ h  _ C_ h_ a_ r_ a_ c_ t_ e_ r
      _ S_ e_ q_ u_ e_ n_ c_ e _ R_ e_ p_ r_ e_ s_ e_ n_ t_ e_ d

         ??=        #
         ??(        [
         ??/        \
         ??)        ]
         ??'        ^
       ??<       {
         ??!        |
       ??>       }
         ??-        ~
The characters represented are the ones used in the C character set but not included in the ISO 646 character set. ISO 646 describes an invariant sub-set of the ASCII character set.
Trigraph sequences are interpreted even if they occur within a string literal or a character constant. Thus, strings that uses a literal ``??'' will not work the same as under a non-ANSI implementation of C. For example, the function call
     printf("Feel lucky, punk??!\n");
would print:
     Feel lucky, punk|
To print a pair of questions marks, use the escape sequence `\??'. For example:
     printf("Feel lucky, punk\??!\n");

0 comments: