[HN Gopher] What does the ??!??! operator do in C? ___________________________________________________________________ What does the ??!??! operator do in C? Author : isomorph Score : 60 points Date : 2022-10-05 21:24 UTC (1 hours ago) (HTM) web link (stackoverflow.com) (TXT) w3m dump (stackoverflow.com) | rdlw wrote: | See also: "What is the "-->" operator in C++?" | | https://stackoverflow.com/q/1642028 | bradford wrote: | Trigraphs make this obfuscated C submission possible: | (https://gist.github.com/Property404/e31b99deb3527159e183) | | I've pasted it here for convenience, but I can't make any | assurances about the formatting: | | // Are you there god??/ ??=define _(please, help) ??=define | _____(i,m, v,e,r,y) r%:%:m ??=define ____ _____(a,f,r,a,i,d) | main(__)<%____(!_(-~-??-((-~-??-!__<<- | ??-!!__)<<-??-(!!__<<!!__))+-~-~-??--~-~ | -~-~-~-~-??-(-~-~-~-~-??-!!__<<-~!!__),- | ??-!__))<%??>%>_(__,___)??<____ (printf("please let me die??/r%d | bottle%s" " of bee%s""""??/n",(!(___ %-~-~!!___))?-- | __+!___++:__+!___++,!(__-!!___) | &&___%-~-~!!___??!??!!(___%-~-~!!___??!??!__ | -(-~!!___))?"":"s",___%-~-??-!!___<-??-!!___? "r on the | wall":"eeeeeeer! Take one down,pass ??/ it | around")&&__&&_(__,___),"mercy I'm in pain")??<??>??> | susam wrote: | I learnt C from the book _The C Programming Language_ written by | Brian W. Kernighan and Dennis M. Ritchie, also known as K &R, | more than 20 years ago. I read the book almost cover to cover all | the way from the preface at the beginning to its three appendices | at the end. As someone who knew very little about computer | science in general and programming languages in particular back | then, this book was formative in my journey of becoming a | programmer and also picking up some computer science skills along | the way. | | Appendix A (Reference Manual) of the book broadened my outlook on | programming languages by providing a glimpse how a programming | language is formally specified. Section A.12 (Preprocessing) of | this appendix specified trigraph sequences. Quoting from the | section: | | > Preprocessing itself takes place in several logically | successive phases that may, in a particular implementation, be | condensed. | | > 1. First, trigraph sequences as described in Par.A.12.1 are | replaced by their equivalents. Should the operating system | environment require it, newline characters are introduced between | the lines of the source file. | | Then section A.12.1 (Trigraph Sequences) further elaborated | trigraph sequences in more detail. Quoting this section below: | | > The character set of C source programs is contained within | seven-bit ASCII, but is a superset of the ISO 646-1983 Invariant | Code Set. In order to enable programs to be represented in the | reduced set, all occurrences of the following trigraph sequences | are replaced by the corresponding single character. This | replacement occurs before any other processing. | ??= # ??/ \ ??' ^ ??( [ ??) ] | ??! | ??< { ??> } ??- ~ | | > No other such replacements occur. | | > Trigraph sequences are new with the ANSI standard. | chromatin wrote: | Wow, and I thought I knew C pretty well. Great post. | | edited to add: I really like "Modern C" and just re-checked -- no | mention of the preprocessor feature! | | https://hal.inria.fr/hal-02383654/file/ModernC.pdf | richbell wrote: | I think C also has the elusive "down to" operator. | | https://stackoverflow.com/a/1642035 | [deleted] | kenniskrag wrote: | trigraphs are removed in c++ 17 | | https://en.m.wikipedia.org/wiki/C%2B%2B17#Removed_features | amelius wrote: | I've never seen them used anywhere. | Rebelgecko wrote: | They're good for obfuscating source code but AFAICT that's | about it on modern machines | pjmlp wrote: | They are still around in C though. | KerrAvon wrote: | gone in C23 | david2ndaccount wrote: | They are being removed in C23. | piesquaredarr wrote: | Huh, I never realized that C++ standards were _removing_ C | features. Time to be more careful about using g++ for | everything. | Denvercoder9 wrote: | C++ has never been a strict superset of C. The most obvious | example is the "class" and "new" keywords which can be used | as an identifier in C, but not in C++. There's more subtle | differences as well, such as character literals having type | int in C and char in C++. | turminal wrote: | Using g++ for C code is a recipe to get badly burnt - for | unrelated reasons. Trigraphs are disabled in gcc by default | anyway. ___________________________________________________________________ (page generated 2022-10-05 23:00 UTC)