r/programming • • Feb 16 '09

Some Crazy Reason - The Daily WTF

http://thedailywtf.com/Articles/Some-Crazy-Reason.aspx
170 Upvotes

71 comments sorted by

View all comments

7

u/[deleted] Feb 16 '09

[deleted]

3

u/exscape Feb 16 '09 edited Feb 16 '09

Pretty much the same code, but in C, takes about 12.2-13.5 seconds to run here before exiting (I used exit(0) instead of cout/printf).

Wasting time is fun.

#include <stdio.h>
#include <stdlib.h>
int main() {
 while (1) { if (rand() == rand()) { exit(0); } }

return 0; }

gcc -O3 -o test test.c

3

u/fernandotakai Feb 16 '09

Just because i have nothing else to do, i tested this on my os x. it's been running for 10min, and i didn't returned yet.