troydhanson / uthash

C macros for hash tables and more
Other
4.18k stars 926 forks source link

How can get List of array? #120

Closed QuestionPython closed 7 years ago

QuestionPython commented 7 years ago

Hello, How can get List of array?

#include <stdio.h>
#include "utarray.h"
typedef struct example_user_t {
    int id;
    int cookie;
} example_user_t;
static UT_icd icd = {
    .sz = sizeof(example_user_t),
    .init = NULL,
    .copy = NULL,
    .dtor = NULL
};
int main()
{
    UT_array users;
    utarray_init(&users, &icd);
    for (int i=1; i<=100000000; i++)
    {
        example_user_t user = {i, i*i};
        utarray_push_back(&users, &user);
    }
    printf("%d\n",users.i);
    for (int i=1; i<=users.i;i++)
    {

Please Help me complate this place

    }

}

also how can remove a index from array? example _remove(&users,5);

tbeu commented 7 years ago

Did you already try utarray_next for the looping and utarray_erase for the removal?

Quuxplusone commented 7 years ago

@questionpython: This kind of "how do I do X with library Y" question is probably better suited to StackOverflow, as opposed to opening an issue against the project every time you have a question.

Documentation for utarray is available here.