← Back

miniblog

Thoughts, notes, and things I find interesting.


TIL: Quirkiness of C|C++

Digraphs! A legacy of C, inherited by C++, that, back in the day, was useful for writing some correct, although pretty obscure code due to some constraints on characters like '# { } [ ]'. Let's take a look at the following hello, world! program:

%:include<iostream>

using namespace std;

int main()
<%
    cout << "hello, world!" << std::endl;
    return 0;
%>

Pretty cool, right? Trigraphs also exist but they are disabled on most compilers by default. Please don't use them in production code.