OpenersNotesSection(Spacer1)Details

A raw backslash in the string must be sent as two characters '∖∖'.

Special characters can be sent only using the format returned by (NonWLLink[WSGetString(), paclet:ref/c/WSGetString]).

The encoding normally used is the same as for (NonWLLink[WSGetString(), paclet:ref/c/WSGetString]).

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

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

WSPutString() is declared in the WSTP header file (RefLink[wstp.h, paclet:ref/file/wstp.h]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)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 */ }

}

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(NonWLLink[WSPutByteString(), paclet:ref/c/WSPutByteString])  ▪  (NonWLLink[WSPutUCS2String(), paclet:ref/c/WSPutUCS2String])  ▪  (NonWLLink[WSPutUTF8String(), paclet:ref/c/WSPutUTF8String])  ▪  (NonWLLink[WSPutUTF16String(), paclet:ref/c/WSPutUTF16String])  ▪  (NonWLLink[WSPutUTF32String(), paclet:ref/c/WSPutUTF32String])  ▪  (NonWLLink[WSPutSymbol(), paclet:ref/c/WSPutSymbol])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Manipulating Expressions in External Programs, paclet:tutorial/ManipulatingExpressionsInExternalPrograms])}, {▪(RefLinkPlain[Handling Lists, Arrays and Other Expressions, paclet:tutorial/HandlingListsArraysAndOtherExpressions])}, {▪(RefLinkPlain[Portability of WSTP Programs, paclet:tutorial/PortabilityOfWSTPPrograms])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Mac OS X), paclet:tutorial/WSTPDeveloperGuide-MacintoshOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Unix and Linux), paclet:tutorial/WSTPDeveloperGuide-UnixOverview])}, {▪(RefLinkPlain[WSTP C API Developer Guide (Windows), paclet:tutorial/WSTPDeveloperGuide-WindowsOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Alphabetical Listing of WSTP C Functions, paclet:guide/AlphabeticalListingOfWSTPCFunctions])}, {▪(RefLinkPlain[C/C++ Language Interface, paclet:guide/CLanguageInterface])}, {▪(RefLinkPlain[WSTP API, paclet:guide/WSTPAPI])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Data, paclet:guide/WSTPCFunctionsForExchangingData])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Expressions, paclet:guide/WSTPCFunctionsForExchangingExpressions])}, {▪(RefLinkPlain[WSTP C Functions for Exchanging Strings, paclet:guide/WSTPCFunctionsForExchangingStrings])}, {▪(RefLinkPlain[WSTP C Language Functions, paclet:guide/WSTPCLanguageFunctions])}})}})