Added extern C and replaced writeln call with printf