Skip to content

Instantly share code, notes, and snippets.

@sw17ch
Forked from manlycode/gist:1896012
Created February 24, 2012 14:17

Revisions

  1. @manlycode manlycode created this gist Feb 24, 2012.
    8 changes: 8 additions & 0 deletions gistfile1.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    int truncate_and_call(fn_ptr *fns, int index, char *user_string)
    {
    char buf[64];
    // Truncate supplied string
    strncpy(buf, user_string, sizeof(buf) - 1);
    buf[sizeof(buf) - 1] = '\0';
    return fns[index](buf);
    }