CPP Hacks.

Jun. 25th, 2006 03:03 am
swestrup: (Default)
[personal profile] swestrup
For ages I've belived that one couldn't paste a "\" in front of a "n" in C and have it produce a newline (\n). Well, you can. This works:
#include <stdio.h>

#define slash() \ //slash

#define strize(x) #x
#define strevl(x) strize(x)

#define slashit(x) strevl(slash()x)

int main(void)
  {
    printf("[%s]\n", slashit(n));
  }
produces the output:
[
]
As one might hope.

Date: 2006-06-25 07:12 am (UTC)
From: [identity profile] wintersweet.livejournal.com
It seems a bit friends-page-breaky. o_O

Date: 2006-06-25 05:45 pm (UTC)

January 2017

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Feb. 13th, 2026 05:14 pm
Powered by Dreamwidth Studios