ところで、CをCGIとして使う場合、Perlのようにしなければならないんでしょうか?

たとえば
ローカルでは
print "hello";

サーバーでは
print header;
print "hello";

のように。