Difference between revisions of "Prokee Module: mstr"

From prokee
Jump to navigation Jump to search
(Created page with "The module '''mstr''' provides basic functionality for strings (like copying, concatenation and comparison) with automated reallocation of larger memory blocks, if required....")
 
(Example)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
The module '''mstr''' provides basic functionality for strings (like copying, concatenation and comparison) with automated reallocation of larger memory blocks, if required.
 
The module '''mstr''' provides basic functionality for strings (like copying, concatenation and comparison) with automated reallocation of larger memory blocks, if required.
 +
 +
== Example ==
 +
<syntaxhighlight lang="C">
 +
mstrs<char> *a;
 +
mstr::create(&a,10);              // initial memory allocation of 10 Bytes
 +
mstr::copy_str(a,"Hello World!"); // copying of a string (allocates a larger memory block for 'a')
 +
printf("%s\n",mstr::c_str(a));
 +
mstr::destroy(a);                // frees all memory allocated for 'a'
 +
</syntaxhighlight>
  
 
== Implementations ==
 
== Implementations ==

Latest revision as of 13:29, 12 June 2019

The module mstr provides basic functionality for strings (like copying, concatenation and comparison) with automated reallocation of larger memory blocks, if required.

Example

mstrs<char> *a;
mstr::create(&a,10);              // initial memory allocation of 10 Bytes
mstr::copy_str(a,"Hello World!"); // copying of a string (allocates a larger memory block for 'a')
printf("%s\n",mstr::c_str(a));
mstr::destroy(a);                 // frees all memory allocated for 'a'

Implementations