snippet     if
options     head
abbr        if () {}
    if (${1:#:condition}) {
        ${0:TARGET}
    }

snippet else
options     head
    else {
        ${0:TARGET}
    }

snippet elseif
options     head
    else if (${1:#:condition}) {
        ${0:TARGET}
    }

snippet     ifelse
options     head
abbr        if () {} else {}
    if (${1:#:condition}) {
        ${2:TARGET}
    } else {
        ${3}
    }

snippet     for
options     head
abbr        for () {}
    for (${1:int} ${2:i} = ${3:0}; $2 < ${4}; $2++) {
        ${0:#:TARGET}
    }

snippet     while
options     head
abbr        while () {}
    while (${1:#:condition}) {
        ${0:TARGET}
    }

snippet     do_while
options     head
alias       do
    do {
        ${0:TARGET:code}
    } while (${1:#:condition});

snippet     switch
options     head
abbr        switch () {}
    switch (${1:#:var}) {
        case ${2:#:val}:
            ${0:TARGET}
            break;
    }

snippet     function
options     head
alias       func
abbr        func() {}
    ${1:void} ${2:#:func_name}(${3:#:args}) {
        ${0:TARGET}
    }

snippet     struct
options     head
abbr        struct {}
    struct ${1:#:name} {
        ${0:TARGET:data}
    };

# Typedef struct
snippet struct_typedef
options     head
    typedef struct ${1:#:name} {
        ${0:TARGET:data}
    };

snippet     enum
options     head
abbr        enum {}
    enum ${1:#:name} {
        ${0:TARGET}
    };

# hard-tab is necessary; C indent doesn't support this.
snippet main
options     head
	int main(int argc, char const* argv[])
	{
		${0:TARGET}
		return 0;
	}

# #include <...>
snippet inc
options     head
alias   #inc, #include
    #include <${1:stdio}.h>${0}
# #include "..."
snippet inc2
options     head
alias   #inc2, #include2
    #include "${1}.h"${0}

snippet ifndef
options     head
alias   #ifndef
abbr #ifndef ... #define ... #endif
    #ifndef $1
    #define ${1:#:SYMBOL}
    #endif${0}

snippet def
options     head
alias   #def, #define
    #define 

# Include-Guard
snippet once
options     head
abbr include-guard
    #ifndef ${1:SYMBOL}
        #define $1

        ${0:TARGET}
    #endif /* end of include guard */

# Ternary conditional operator
snippet conditional
    (${1:#:condition}) ? ${2:#:a} : ${3:#:b}

snippet typedef
    typedef ${1:#:base_type} ${2:#:custom_type};

snippet printf
abbr    printf("...\n", ...);
    printf("${1}\n", ${2});

snippet fprintf
abbr    fprintf(..., "...\n", ...);
    fprintf(${1:stderr}, "${2}\n"${3});

snippet comment
alias /*
    /* ${1:#:comment} */
    ${0}

snippet sizeof
alias size
    sizeof(${0:TARGET})

snippet helloworld
options     head
    #include <stdio.h>
    int main(int argc, char const* argv[])
    {
        puts("hello, world!");
        return 0;
    }

snippet fopen
abbr fopen("...", "...");
    fopen("${1:PATH}", "${2:MODE}");
    ${0:TARGET}
    fclose(${3:FD});

snippet fgets
abbr fgets(row, length, file);
    fgets(${0:ROW}, ${1:LENGTH}, ${2:FILE});