maintenance.c
/* remove one item from table whose table field name is the argument */
remove one item from table whose table field name is the argument
remove one item from table whose table field name is the argument
int remove_from_database(char name[MAX_CHARS])
{
    sqlite3 *db;
    int rc = sqlite3_open_v2("items.db", &db, SQLITE_OPEN_READWRITE, NULL);
    if (rc)
    {
        fprintf(stderr, "Cannot open database: %s\n", sqlite3_errmsg(db));
        return 1;
    }
    sqlite3_stmt *stmt;
    char *delete_query = sqlite3_mprintf("DELETE FROM clothing "
                                         "WHERE name='%s';",
                                         name); 
    rc = sqlite3_prepare_v2(db, delete_query, -1, &stmt, NULL);
    if (rc != SQLITE_OK)
    {
        printf("error: %s\n", sqlite3_errmsg(db));
        return 1;
    }
    rc = sqlite3_step(stmt);
    sqlite3_finalize(stmt);
    sqlite3_close(db);
    return 0;
}
int remove_from_database ( char name [ MAX_CHARS ] ) { sqlite3 * db ; int rc = sqlite3_open_v2 ( " " , & db , SQLITE_OPEN_READWRITE , NULL ) ; if ( rc ) { fprintf ( stderr , " \n " , sqlite3_errmsg ( db ) ) ; return 1 ; } sqlite3_stmt * stmt ; char * delete_query = sqlite3_mprintf ( " " " " , name ) ; rc = sqlite3_prepare_v2 ( db , delete_query , -1 , & stmt , NULL ) ; if ( rc != SQLITE_OK ) { printf ( " \n " , sqlite3_errmsg ( db ) ) ; return 1 ; } rc = sqlite3_step ( stmt ) ; sqlite3_finalize ( stmt ) ; sqlite3_close ( db ) ; return 0 ; }
remove one item from table whose table field name is the argument
remove one item from table whose table field name is the argument
//printf("%s\n", delete_query);