Happy Birthday Program I'm trying to teach myself C. I've managed to make this program I call HappyToYou.c (inspired by this video):

#include &lt;stdio.h&gt;
//#include &lt;stdlib.h&gt; //malloc would need this.
#include &lt;string.h&gt;
#include &lt;err.h&gt;

void sing(char *start, char *end){
    printf("%s%s.\n", start, end);
}

int main(int argc, char *argv[]){
    if(argc!=3) errx(1, "Give a holiday and a name as arguments.");

    char *happy="Happy ";
    char start[strlen(happy)+strlen(argv[1])+1];
    strcpy(start, happy);
    strcat(start, argv[1]);
    char *to=" to you";


    char *dear=" dear, ";
    char person[strlen(dear)+strlen(argv[2])+1];
    strcpy(person, dear);
    strcat(person, argv[2]);

    sing(start, to);
    sing(start, to);
    sing(start, person);
    sing(start, to);

    return 0;
}


I think it is free from bugs (as far as I know). I'm pretty sure it can be trimmed down but I'm not sure how.
There're some bugs in the code. For example, if the user provides more inputs than needed, which the program could safely ignore (or warn about), it'll still exit with an error and an incorrect message.

The comparison should be updated to: if (argc &lt; 3)

Although I think the first answer is ok, I think the readability of the code counts, and proper indentation makes a huge difference. You should develop this habit from the start and I'd find the following minor modifications slightly more preferable, IMHO:

#include &lt;stdio.h&gt;
#include &lt;error.h&gt;

int main(int argc, char *argv[]) {
    /* notice the logical operator update here; prevents bogus error
       message if user provides more than 2 inputs */
    if (argc &lt; 3)
        errx(1, "Give a holiday and a name as arguments.");

    printf(
        "Happy %1$s to you.\n"
        "Happy %1$s to you.\n"
        "Happy %1$s, dear %2$s!\n"
        "Happy %1$s to you.\n",
        argv[1],
        argv[2]
    );

    return 0;
}


Also, I'd recommend that you get in the habit of writing user-visible messages using user-friendly terminology, especially when error conditions are detected.

For example, instead of saying "Give a holiday and name as arguments", which relies on programmer terminology (e.g. non-programmers are unlikely to know what "arguments" are), try to be user-friendly. Consider if the program instead said the following during the error and helped the user correct it:

Some inputs appear to be missing. Please enter the holiday and your name.
Usage: HappyToYou &lt;holiday&gt; &lt;name&gt;
Example: HappyToYou Birthday Bob


Few things are more frustrating than error messages that are uninformative or wrong because the former doesn't help you resolve the issue and the latter sends the user down the wrong path in trying to find a solution.