Tizen Native API
8.0
|
Eina inline array of strings
This example creates an inline array of strings, adds some elements, and then prints them. This example is based on Basic array usage and Eina inline array usage.
We start with some variable declarations and eina initialization:
int main(int argc EINA_UNUSED, char **argv EINA_UNUSED) { const char* strings[] = { "helo", "hera", "starbuck", "kat", "boomer", "hotdog", "longshot", "jammer", "crashdown", "hardball", "duck", "racetrack", "apolo", "husker", "freaker", "skulls", "bulldog", "flat top", "hammerhead", "gonzo" }; char **str, **str2; Eina_Inarray *iarr; int i; eina_init();
We then create the array much like we did on Eina inline array usage :
iarr = eina_inarray_new(sizeof(char *), 0);
The point is this example significantly differs from the first eina inline array example. We are not going to add the strings themselves to the array since their size varies, we are going to store a pointer to the strings instead. We therefore use char**
to populate our inline array:
for (i = 0; i < 20; i++){ str = (char **)(&strings[i]); eina_inarray_push(iarr, str); }
The source for this example: eina_inarray_02.c