Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

No Semicolon Printing

$
0
0
So my instructor has a penchant for asking tricky questions, last day he asked how to print Hello, World in C without typing a single semicolon. There are several answers to this like the if/while/switch statements or printing inside the argument of the main function. However one answer I found on a site was way different, he talked about stealing a semicolon from a header file. Here's the code:
int main(int ac, char **av)
{
#define typedef
#define uint8_t a[printf("Hello, World\n")]
#include <stdint.h>
}


Can you Please explain me how this works? I know uint8_t is a byte representation but still I have no clue. I also read that this doesn't work on FreeBSD. Why so?
Thanks.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>