Example #1
0
int main()
{
    Trie t;
    string input = "";
    cout << "Please type a command: 'insert', 'isPrefix', 'isWord', " << endl;
    cout << "'remove', 'print', 'remove_all', 'num_words' " << endl;
    cout << "or 'end' to end the program. " << "Input is case sensitive.";
    cout << endl;
    while(input != "end")
    {
        cout << "Command: ";
        cin >>input;
        if( input == "insert" )
            run_insert(&t);
        else if( input == "isPrefix" )
            run_isPrefix(&t);
        else if( input == "isWord" )
            run_isWord(&t);                 // Pass the trie by reference.
        else if( input == "remove" )
            run_remove(&t);
        else if( input == "print" )
            run_print(&t);
        else if( input == "remove_all" )
            run_remove_all(&t);
        else if( input == "num_words" )
            run_num_words(&t);
    }
    return 0;
}
Example #2
0
int main(int argc, char *argv[])
{
    enum COMMAND cmd;

    show_banner();

    switch (parse_commandline(argc, argv)) {
    case COMMAND_INSTALL:
        return run_install(param0, param1);
    case COMMAND_REMOVE:
        return run_remove(param0);
    case COMMAND_CREATE:
        return run_create(param0, param2, param1);
    case COMMAND_UNPACK:
        return run_unpack(param0, param1);
    case COMMAND_UNDEFINED:
    default:
        show_usage();
        return 1;
    }

    return EXIT_SUCCESS;
}