WSPutString (C Function)
int WSPutString(WSLINK link,const char*s)
puts a null-terminated string of C characters to the WSTP connection specified by link.
Details
- A raw backslash in the string must be sent as two characters '∖∖'.
- Special characters can be sent only using the format returned by WSGetString().
- The encoding normally used is the same as for WSGetString().
- WSPutString() returns 0 in the event of an error, and a nonzero value if the function succeeds.
- Use WSError() to retrieve the error code if WSPutString() fails.
- WSPutString() is declared in the WSTP header file wstp.h.
Examples
Basic Examples (1)
#include "wstp.h"
/* send a string representing an expression to a Mathematica kernel
for evaluation */
void f(WSLINK lp)
{
/* construct the packet to be sent to the kernel */
WSPutFunction(lp, "EvaluatePacket", 1);
WSPutFunction(lp, "ToExpression", 1);
WSPutString(lp, (const char *)"3+4/Sqrt[19.2]");
WSEndPacket(lp);
/* send the packet */
if(! WSFlush(lp))
{ /* unable to flush an outgoing data buffered in lp */ }
}