WSGetString (C Function)
int WSGetString(WSLINK link,const char **s)
gets a character string from the WSTP connection specified by link, storing the string in s.
Details
- WSGetString() allocates memory for the character string. You must call WSReleaseString() to disown this memory. If WSGetString() fails and the function's return value indicates an error, do not call WSReleaseString() on the contents of s.
- WSGetString() returns immutable data.
- WSGetString() creates a string that is terminated by ∖0.
- WSGetString() stores single ∖ characters from the Wolfram Language as pairs of characters ∖∖.
- WSGetString() stores special characters from the Wolfram Language in a private format.
- WSGetString() returns 0 in the event of an error, and a nonzero value if the function succeeds.
- Use WSError() to retrieve the error code if WSGetString() fails.
- WSGetString() is declared in the WSTP header file wstp.h.
Examples
Basic Examples (1)
#include "wstp.h"
/* read a string from a link */
void f(WSLINK lp)
{
const char *string;
if(! WSGetString(lp, &string))
{
/* unable to read the string from lp */
return;
}
/* ... */
WSReleaseString(lp, string);
}