\hypertarget{eina_array_01_8c-example}{}\section{eina\+\_\+array\+\_\+01.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -g eina\_array\_01.c -o eina\_array\_01 `pkg-config --cflags --libs eina`}

\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <string.h>}

\textcolor{preprocessor}{#include <\hyperlink{Eina_8h}{Eina.h}>}

\textcolor{keyword}{static} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}
\_print(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *container \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{void} *data, \textcolor{keywordtype}{void} *fdata EINA\_UNUSED)
\{
  printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, (\textcolor{keywordtype}{char} *)data);
   \textcolor{keywordflow}{return} \hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE};
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}, \textcolor{keywordtype}{char} **argv \hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED})
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char}* strings[] = \{
      \textcolor{stringliteral}{"helo"}, \textcolor{stringliteral}{"hera"}, \textcolor{stringliteral}{"starbuck"}, \textcolor{stringliteral}{"kat"}, \textcolor{stringliteral}{"boomer"},
      \textcolor{stringliteral}{"hotdog"}, \textcolor{stringliteral}{"longshot"}, \textcolor{stringliteral}{"jammer"}, \textcolor{stringliteral}{"crashdown"}, \textcolor{stringliteral}{"hardball"},
      \textcolor{stringliteral}{"duck"}, \textcolor{stringliteral}{"racetrack"}, \textcolor{stringliteral}{"apolo"}, \textcolor{stringliteral}{"husker"}, \textcolor{stringliteral}{"freaker"},
      \textcolor{stringliteral}{"skulls"}, \textcolor{stringliteral}{"bulldog"}, \textcolor{stringliteral}{"flat top"}, \textcolor{stringliteral}{"hammerhead"}, \textcolor{stringliteral}{"gonzo"}
   \};
   \hyperlink{struct__Eina__Array}{Eina\_Array} *array;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} i;

   \hyperlink{group__Eina__Main__Group_gabf448ada5bc81a07342b66c6f818ee5e}{eina\_init}();

   array = \hyperlink{group__Eina__Array__Group_ga4a389204db37b44b31d29f581258ac7d}{eina\_array\_new}(10);
   \hyperlink{group__Eina__Array__Group_ga310eb050803ee5d4d2894d322f4c088f}{eina\_array\_step\_set}(array, \textcolor{keyword}{sizeof}(*array), 20);

   \textcolor{keywordflow}{for} (i = 0; i < 20; i++)
     \hyperlink{group__Eina__Array__Group_gaf2f4a5907f1826354977adbd63e3379a}{eina\_array\_push}(array, strdup(strings[i]));

   printf(\textcolor{stringliteral}{"array count: %d\(\backslash\)n"}, \hyperlink{group__Eina__Array__Group_ga803b2c0bde44a344dd55d790235c254e}{eina\_array\_count}(array));
   \hyperlink{group__Eina__Array__Group_ga8de2d191a0fffceb5bdc6376540b8db1}{eina\_array\_foreach}(array, \_print, NULL);

   printf(\textcolor{stringliteral}{"Top gun: %s\(\backslash\)n"}, (\textcolor{keywordtype}{char}*)\hyperlink{group__Eina__Array__Group_ga3c8c1ae6e979cc7b4890421ec63543f1}{eina\_array\_data\_get}(array, 2));

   \textcolor{keywordflow}{while} (\hyperlink{group__Eina__Array__Group_ga803b2c0bde44a344dd55d790235c254e}{eina\_array\_count}(array))
     free(\hyperlink{group__Eina__Array__Group_gaffa602b526b5da4d2b59910f68dd270f}{eina\_array\_pop}(array));

   \hyperlink{group__Eina__Array__Group_ga97995d81ca401d71a2913a52f8b40c41}{eina\_array\_free}(array);

   \hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\_shutdown}();

   \textcolor{keywordflow}{return} 0;
\}
\end{DoxyCodeInclude}
 