Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

recursive main()

2»

Comments

  • thefamousblurtthefamousblurt Member Posts: 3
    please delete this post - script filter said that 'submit' did not work.
  • thefamousblurtthefamousblurt Member Posts: 3
    Hi, I did this, for a self-documenting [b]& running[/b] program which runs its own example:
    [code]
    #include
    etc, etc, etc

    #define CAPACITY_OF(array) (sizeof(array)/sizeof(array[0]))

    /* Prototype for mainly() function */
    int mainly(int argc, char *argv[]); /* Recursively calling main not allowed. */

    /**********************************************/
    void usage(FILE *file)
    {
    char *example[] = {
    "lgchr", "-w", "79", "-b", "3", "-C", "-s", "c", "-n", "Doh!" };



    // Now run the program using the example:
    mainly(CAPACITY_OF(example), example);
    }
    /**********************************************/
    int main(int argc, char *argv[])
    {
    return mainly(argc, argv);
    }
    /**********************************************/
    int mainly(int argc, char *argv[])
    {


    if < an option is '-h' >
    {
    usage(stdout);
    exit(1);
    }


    }[/code]This results in:[code]$ lgchr -h
    lgchr 5.1 (c) 1991-2012 Alf Lacis Build:20120622.151856

    lgchr: create headers in various sizes to include in source code, text files, etc.

    Usage:
    lgchr [-s style] [-b n] [-t value|a|i] [-c [c|r|b|d]] [-w minw] [-C] [-n] [-f file]|[string1 [string2...]] >out

    Where:
    STYLE CASE ASCII FIXED/PROP BLANKS
    -s style ===== =========== ========= ============ ======
    a 16x12 UPPER+lower 32 -> 127 proportional 1
    b 12x12 UPPER ONLY 32 -> 95 proportional 1
    c 12x7 UPPER+lower 32 -> 127 proportional 2
    d 9x5 UPPER+lower(*) 32 -> 127 proportional 1
    e 7x5 UPPER ONLY 32 -> 95 proportional 1
    f 7x4 UPPER+special(#) 32 -> 96 fixed fixed

    (*) Default style is d = 9x5.
    (#) Non-ASCII characters are declared in 97 to 127.

    -b n Number of blanks between letters

    -t a means use the character to make the large letter (default=@)
    i means use the IBM square block character (decimal 219)
    value a value in decimal for the character to be displayed

    -c c Comments: C format: "/*..." Default is C++: "//..."
    -c r raw format: just the text, not a C or C++ header
    -c b bash format: use '#' for the comment start (also perl, etc)
    -c d dos format: use 'REM ' for the comment start

    -w minw Minimum width of top & bottom 'lines', default is 100

    -C Centre the heading within the minimum width: also see -w

    -n No empty lines above & below text

    -f file Read rows of strings from this file

    string1, string2, etc - strings to be converted

    Note: Maximum output line length as at Jun 22 2012 is 20480.

    Example:
    lgchr -w 79 -b 3 -C -s c -n Doh!
    ///////////////////////////////////////////////////////////////////////////////
    @
    // @ @
    // @ @
    // @
    // @ @ @ @ @
    // @ @ @ @ @
    // @ @ @ @ @
    // @ @ @ @
    @ @
    ///////////////////////////////////////////////////////////////////////////////
    [email protected] ~
    $[/code]
2»
Sign In or Register to comment.