

First thing always is including Eina\+: 
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}

\end{DoxyCodeInclude}


Next we initialize eina and create a string buffer to play with\+: 
\begin{DoxyCodeInclude}

\textcolor{keywordtype}{int} main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} **argv \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   \mbox{\hyperlink{struct__Eina__Strbuf}{Eina\_Strbuf}} *buf, *substr;

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

   buf = \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga6f3c9ce942e61364a10ec7c0ea01cedc}{eina\_strbuf\_new}}();

\end{DoxyCodeInclude}


Here you can see two different ways of creating a buffer with the same contents. We could create them in simpler ways, but this gives us an opportunity to demonstrate several functions in action\+: 
\begin{DoxyCodeInclude}

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_gaad4f562f3a36881f12a4df5154e04b26}{eina\_strbuf\_append\_length}}(buf, \textcolor{stringliteral}{"BUFFE"}, 5);
   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga8afef8fb6f9aedcd6a81603bef0c7f86}{eina\_strbuf\_append\_char}}(buf, \textcolor{charliteral}{'R'});
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_gaa6fbcb0fdebd3e8ec9ba466c2c7b3aaa}{eina\_strbuf\_tolower}}(buf);
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   substr = \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga4c68ed255853465641092387f2bb14c9}{eina\_strbuf\_substr\_get}}(buf, 3, 2);
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(substr));
   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga482e9f90bc8e0e17811e825975a2ba85}{eina\_strbuf\_free}}(substr);

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga04719a5613488bbbd17f9eb75933d2c1}{eina\_strbuf\_insert\_escaped}}(buf, \textcolor{stringliteral}{"my "}, 0);
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));
   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga9f3435de2169ee40306c0111fa1a60b6}{eina\_strbuf\_reset}}(buf);

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga408b371f57f35a8f5391c2e85ab28b35}{eina\_strbuf\_append\_escaped}}(buf, \textcolor{stringliteral}{"my buffer"});
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));
   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga9f3435de2169ee40306c0111fa1a60b6}{eina\_strbuf\_reset}}(buf);

\end{DoxyCodeInclude}


Next we use the printf family of functions to create a formated string, add, remove and replace some content\+: 
\begin{DoxyCodeInclude}

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga436897daafadbf56f2e3d7c0d4d21040}{eina\_strbuf\_append\_printf}}(buf, \textcolor{stringliteral}{"%s%c"}, \textcolor{stringliteral}{"buffe"}, \textcolor{charliteral}{'r'});
   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga8dca9fa4f4d792e32ab0b3b3542de8ab}{eina\_strbuf\_insert\_printf}}(buf, \textcolor{stringliteral}{" %s: %d"}, 6, \textcolor{stringliteral}{"length"}, (\textcolor{keywordtype}{int})
      \mbox{\hyperlink{group__Eina__String__Buffer__Group_gaa6ef2a1cb7f79070508e6bf158caeccc}{eina\_strbuf\_length\_get}}(buf));
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_gac7ead92f4ce23c16b7a33d40ce3bf5cd}{eina\_strbuf\_remove}}(buf, 0, 7);
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_gab86cdc70b13b7f6b1c168ed2b563d600}{eina\_strbuf\_replace\_all}}(buf, \textcolor{stringliteral}{"length"}, \textcolor{stringliteral}{"size"});
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

\end{DoxyCodeInclude}


Once done we free our string buffer, shut down Eina and end the application\+: 
\begin{DoxyCodeInclude}
   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga482e9f90bc8e0e17811e825975a2ba85}{eina\_strbuf\_free}}(buf);

   buf = \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga5ae85082ac2f6a00621b4a5703850759}{eina\_strbuf\_manage\_read\_only\_new\_length}}(\textcolor{stringliteral}{"Example string"}, 1
      4);
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga8afef8fb6f9aedcd6a81603bef0c7f86}{eina\_strbuf\_append\_char}}(buf, \textcolor{charliteral}{'.'});
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_gaad4f562f3a36881f12a4df5154e04b26}{eina\_strbuf\_append\_length}}(buf, \textcolor{stringliteral}{"Another string."}, 15);
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga66c7c19a2b240448fbd2dae6c6161023}{eina\_strbuf\_string\_get}}(buf));

   \mbox{\hyperlink{group__Eina__String__Buffer__Group_ga482e9f90bc8e0e17811e825975a2ba85}{eina\_strbuf\_free}}(buf);
   \mbox{\hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\_shutdown}}();

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

\end{DoxyCodeInclude}
 