oscarbonilla.com

Hidden Gems in C99 (1)

with 2 comments

After some late night reading of the C99 spec, I’ve found quite a few hidden gems. I’m going to start posting some of these. Since it’s late, I’ll just post a teaser.

On page 64 of the C99 standard it says:

In all aspects of the language, the six tokens

<: :> <% %> %: %:%:

behave,respectively,the same as the six tokens

[ ] { } # ##

except for their spelling.

Really? Then let’s try this program:

%:include <stdio .h>
int
main(int argc, char *argv<::>)
<%
	printf("hello world\n");
%>

Compile it an run it:

dirac src $ gcc main.c
dirac src $ ./a.out
hello world

Whaddaya know… I know, I know… useless. Wait for the next post then.

Written by ob

April 11th, 2008 at 11:57 pm

Posted in Uncategorized

Tagged with ,

2 Responses to 'Hidden Gems in C99 (1)'

Subscribe to comments with RSS or TrackBack to 'Hidden Gems in C99 (1)'.

  1. [...] Ramblings Stuff that’s on my mind « Hidden Gems in C99 (1) [...]

  2. Me imagino que son iguales que los trigraphs del estándar viejo…para los teclados sin caracteres especiales?

    efutch

    1 Feb 09 at 8:25 pm

Leave a Reply