# AppendString

int AppendString (char **pointerToStringToAppendTo, const char stringToAppend[], int numCharactersToAppend);

## Purpose

Appends all or some of the characters from one string to the end of another string.

The following example may be run in the Interactive Execution window:

#include "toolbox.h"

static char *string;

/* allocate a new string */

string = StrDup("Cats");

/* prints 'Cats' */

printf("string = '%s'\n", string);

/* append to the string */

AppendString(&string, " And Dogs", –1);

/* prints 'Cats And Dogs' */

printf("string = '%s'\n", string);

## Parameters

Input
Name | Type | Description
stringToAppend | const char [] | Pass the string to append to the end of the other string.
numCharactersToAppend | integer | Specifies how many characters of stringToAppend are to be appended. If this value is greater than the number of characters in the string, then only the characters in the string are appended. Pass –1 to append the entire stringToAppend.
Output
Name | Type | Description
pointerToStringToAppendTo | char ** | Pass a pointer to the string to which to append the other string. This parameter must be the address of variable that holds a pointer to a dynamically allocated nul–terminated string. (The variable can contain NULL.) A dynamically allocated string is a string whose memory was allocated by the malloc or calloc functions or by a function that calls malloc or calloc (such as StrDup). The value in the variable will be changed if a new memory block is needed to provide room for the additional characters. Otherwise, the string pointed to is reallocated in place to provide room for the new characters.

## Return Value

Name | Type | Description
result | integer | The return value of this function is 1 if the append succeeded or 0 if there was not enough memory to append the characters.