Set length: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
Created page with '{{ #vardefine:name|set_length}}{{ #vardefine:return_type|void}}{{ FunctionPage| name={{#var:name}}| function_category=String Handling Routines| function1={{Function| name={{#va…'
 
imported>Bale
No edit summary
Line 18: Line 18:
}}|
}}|


function_description=Changes the size of the buffer. If the new length is less than the current length, then the buffer is truncated, losing all characters past that length.|
function_description=Changes the size of the buffer. Primarily this is used to truncate the buffer by setting a new length shorter than the current length, deleting all the characters past that length. If the new length is longer than the old length, the buffer will be padded with null characters: \u0000. Those character can cause trouble, so only use set_length to truncate.|


needscode=yes|
needscode=yes|

Revision as of 04:19, 7 May 2010

needs(code_samples);

Function Syntax

void set_length(buffer original ,int length )

  • original is the buffer to modify
  • length is the new length of the buffer

Changes the size of the buffer. Primarily this is used to truncate the buffer by setting a new length shorter than the current length, deleting all the characters past that length. If the new length is longer than the old length, the buffer will be padded with null characters: \u0000. Those character can cause trouble, so only use set_length to truncate.

See Also

delete() | insert() | length()