Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
752 B
2
Indexable
Never
/* Set to either CHARACTER, WORD or LINE */
scanFragment fragment = CHARACTER;

scanControl scan_func (gint i)
{
    GString* text = NULL;

    /* Obtain fragment */
            if(fragment == CHARACTER)   g_print("%c\n", getcharacter());
    else    if(fragment == WORD)        text = word(GET|CONSUME);
    else    if(fragment == LINE)        text = line(GET|CONSUME);

    /* Print fragment */
    if(text)
        g_print("%s\n", text->str);

    return SCAN_CONTINUE;
}

int main ()
{
    /* Init */
    init_full(TRUE, TRUE, TRUE); /* bool:clearLog bool:remember bool:cache */

    new("Message\nHello ");
    concat(g_get_user_name());

    newscan(CHARACTER);
    foreach(scan_func);
    scan();

    return 0;
}