0

I've created the following little program, I'm going crazy on understanding why it prints "HelloHello" instead of just "Hello". And even strangely if I write 'printf ( "Hello\n" )' instead it works as expected.

I'm running Linux Mint 16 Petra.

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>

int main () {

    printf ( "Hello" );

    switch ( fork () ) {

        case 0:
            exit(0);

        case -1:
            exit(1);

        default:
            exit(0);

    }

}
Fabio Spampinato
  • 717
  • 8
  • 18

0 Answers0