1
\$\begingroup\$

I saw a problem which asks you to print "Hello World" using the fewest characters, including spaces. How can I further shorten this code? Thank you in advance!

#include<iostream>
int main(){printf("Hello World");}
\$\endgroup\$
  • 2
    \$\begingroup\$ See the shortest C++ solution by James in “Hello, World!”. Note that as it is, your question doesn't meet this site's expectations so will be probably closed. \$\endgroup\$ – manatwork Nov 20 '20 at 4:09
  • 3
    \$\begingroup\$ You can remove #include <iostream> and use puts instead of printf (assuming you're using a kind compiler that allows you to use these functions without including cstdio) (edit: it seems that neither G++ nor clang are kind enough and I was wrong) This question should almost certainly be tagged [tips]. \$\endgroup\$ – the default. Nov 20 '20 at 4:10
  • \$\begingroup\$ @manatwork i tried it but i can't compile it. \$\endgroup\$ – Summer Nov 22 '20 at 13:46
  • \$\begingroup\$ @Summer, it works for me: pastebin.com/Qr9hM6g8 Note that as we regularly force the boundaries of compilers/interpreters, warnings are acceptable by default here. \$\endgroup\$ – manatwork Nov 22 '20 at 19:52