As you all know, I am an avid programmer and I especially love learning new programming languages and new paradigms. Lately, I have been thinking a lot about the best way to teach programming to undergraduate students and, during the process, I’ve come across a very nice (and funny) website on the famous HelloWorld program (which Kernighan and Ritchie introduced to the world in their classic The C Programming Language)
The Broken HelloWorld gallery is a collection of 19 badly written HelloWorld programs. For me the most interesting one is the last one which, incredibly, writes more that “Hello World” on standard output (try it!). Here is the program:
#include <stdio .h>
#include <unistd .h>
int main()
{
printf(“Hello “);
if (fork() == 0)
{
printf(“World\n”);
}
return (0);
}
Can you spot the (not so obvious) problem?
Leave a Reply