C supports people that don’t have {curly bracket} keys… #coding #programming #cpp



This is a snippet from my video on the C Iceberg. Here I demonstrate C’s “digraphs” and “trigraphs,” which let you replace curly and square brackets with combinations of other characters.

source

43 Comments

  1. Digraphs are still supported in C++. Unfortunately, Bjarne must have forgotten about them when he introduced the :: operator, because until 2012 you couldn't write the otherwise perfectly valid syntax A<::B> (a templated class A with a template argument B from the global namespace) as it would be turned into A[:B> .
    A special rule had to be added to the C++ tokenizer to fix this; now, when the tokenizer encounters the sequence <:: it checks whether the next character is a colon. If it is, <:: becomes [: . If it isn't, it then checks if the next character is >, and if it isn't, <:: becomes [:
    The things the C++ standards team will put themselves through just for backward compatibility…

  2. um no this is not useless, its very nice for my broken keyboard and if you really hate it you can write a 2 line sed script to replace the digraphs and trigraphs with their original symbols

  3. It isn't useless even nowadays, if some OEM for whatever reason have opted not to include those symbols — and yes, there are such keyboards even nowadays, including touchscreens (with restrictions upon 3rd-party and your own alternatives).

    Oddly enough some have opted to remove the following: < | >

  4. The code you've presented is valid c, however it triggers undefined behavior. You are attempting to initialize a char array of length 3 with a string literal of length 4

Leave a Reply

Your email address will not be published. Required fields are marked *

You might like

© 2026 Cantinho do Vídeo - WordPress Video Theme by WPEnjoy