int WSPutInteger16(WSLINK link,int i)

puts the 16-bit integer i to the WSTP connection specified by link.


  • The argument i is typically declared as short in external programs, but must be declared as int in WSPutInteger16() itself in order to work even in the absence of C prototypes.
  • WSPutInteger16() returns 0 in the event of an error, and a nonzero value if the function succeeds.
  • Use WSError() to retrieve the error code if WSPutInteger16() fails.
  • WSPutInteger16() is declared in the WSTP header file wstp.h.


Basic Examples  (1)

#include "wstp.h"

/* send the expression Times[10,30] to a link */

void f(WSLINK lp)
    short a = 10;
    short b = 30;

    if(! WSPutFunction(lp, "Times", 2))
        { /* unable to put the function to lp */ }

    if(! WSPutInteger16(lp, a))
        { /* unable to put the integer to lp */ }

    if(! WSPutInteger16(lp, b))
        { /* unable to put the integer to lp */ }

    if(! WSEndPacket(lp))
        { /* unable to send the end-of-packet indicator to lp */ }

    if(! WSFlush(lp))
        { /* unable to flush outgoing data to lp */ }

See Also

WSPutInteger32()  WSPutInteger64()