WSPutRealNumberAsUCS2String (C 函数)
int WSPutRealNumberAsUCS2String(WSLINK l, const unsigned short *s)
将一个编码为 UCS2 字符串 s 的浮点数发送到由 l 指定的 WSTP 连接.
更多信息
- 将数字 s 以 "3.14159" 的形式发送.
- 若发生错误,则 WSPutRealNumberAsUCS2String() 返回0;若函数成功,则返回非零值.
- WSTP 的标头文件 wstp.h 已对 WSPutRealNumberAsUCS2String() 作出声明.
范例
基本范例 (1)
#include "wstp.h"
/* A function to put the expression Sqrt[2.75] to a link */
void f(WSLINK l)
{
unsigned short theNumber[5];
theNumber[0] = '2';
theNumber[1] = '.';
theNumber[2] = '7';
theNumber[3] = '5';
theNumber[4] = 0;
if(! WSPutFunction(l, "Sqrt", 1))
{ /* Unable to put Sqrt[] to the link */ }
if(! WSPutRealNumberAsUCS2String(l, theNumber))
{ /* Unable to put the number to the link */}
if(! WSEndPacket(l))
{ /* Unable to put the end-of-packet sequence to l */ }
if(! WSFlush(l))
{ /* Unable to flush any output buffered in l */ }
}