fork fun

Everything todo with programming goes HERE.
Post Reply
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

fork fun

Post by Jonathan »

Just having some fun...

Code: Select all

int i, which=0;
for(i=0; i<4; i++) which |= (fork() > 0) << i;
printf("%i\n", which);
ˌɑrməˈɡɛˌtrɑn
User avatar
warlord x-40
On Lightcycle Grid
Posts: 10
Joined: Mon Jun 06, 2005 5:51 pm

Post by warlord x-40 »

what does that do
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

Probably only (a little) interesting to programmers... It duplicates itself 4 times and prints which one it is.
ˌɑrməˈɡɛˌtrɑn
User avatar
warlord x-40
On Lightcycle Grid
Posts: 10
Joined: Mon Jun 06, 2005 5:51 pm

Post by warlord x-40 »

oh
Post Reply