OpenersNotesSection(Spacer1)Details

MLGetString() allocates memory for the character string. You must call (NonWLLink[MLReleaseString(), paclet:ref/c/MLReleaseString]) to disown this memory. If MLGetString() fails and the function's return value indicates an error, do not call (NonWLLink[MLReleaseString(), paclet:ref/c/MLReleaseString]) on the contents of s.

MLGetString() returns immutable data.

MLGetString() creates a string that is terminated by ∖0.

MLGetString() stores single ∖ characters from the Wolfram Language as pairs of characters ∖∖.

MLGetString() stores special characters from the Wolfram Language in a private format.

MLGetString() returns 0 in the event of an error, and a nonzero value if the function succeeds.

Use (NonWLLink[MLError(), paclet:ref/c/MLError]) to retrieve the error code if MLGetString() fails.

MLGetString() is declared in the MathLink header file (RefLink[mathlink.h, paclet:ref/file/mathlink.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

#include "mathlink.h"

/* read a string from a link */

void f(MLINK lp)
{
	const char *string;

	if(! MLGetString(lp, &string))
		{
			/* unable to read the string from lp */
			return;
		}

	/* ... */

	MLReleaseString(lp, string);
}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[MLGetByteString(), paclet:ref/c/MLGetByteString])  ▪  (NonWLLink[MLGetUCS2String(), paclet:ref/c/MLGetUCS2String])  ▪  (NonWLLink[MLGetUTF8String(), paclet:ref/c/MLGetUTF8String])  ▪  (NonWLLink[MLGetUTF16String(), paclet:ref/c/MLGetUTF16String])  ▪  (NonWLLink[MLGetUTF32String(), paclet:ref/c/MLGetUTF32String])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}})}})