MLBytesToPut (C 函数)
MLBytesToPut 已经被 WSBytesToPut 所取代.
int MLBytesToPut(MLINK link,int *n)
计算当前数据的文本表示中剩余的要写入的字节数,并把结果存在 n 中.
更多信息

- MathLink 提供函数,例如:MLPutString()、MLPutSymbol()、MLPutInteger32() 和 MLPutReal64() 发送字符串、符号、整数和浮点数. 然而,有时使用字符字符串表示发送这些类型很方便. MLBytesToPut() 与 MLPutType()、MLPutRawSize() 和 MLPutRawData() 一起使用字符字符串表示发送一个类型.
- MLBytesToPut() 如果为错误事件返回0,如果函数成功则返回非零值.
- 如果 MLBytesToPut() 失败,使用 MLError() 检索错误代码.
- MLBytesToPut() 在 MathLink 的标头文件 mathlink.h 中被声明.
范例
基本范例 (1)
#include <string.h>
#include "mathlink.h"
/* send an approximation of Pi across a link */
void f(MLINK lp)
{
char *Pi = "3.141592654";
int bytes_left, i;
if(! MLPutType(lp, MLTKOLDREAL))
{ /* unable to send the data type to lp */ }
if(! MLPutRawSize(lp, strlen(Pi))
{ /* unable to send the length of Pi to lp */ }
if(! MLBytesToPut(lp, &bytes_left))
{ /* unable to get the remaining bytes to send from lp */ }
i = 0;
while(bytes_left > 0)
{
/* send the data one byte at a time */
if(! MLPutRawData(lp, Pi + i, 1))
{ /* unable to send a character of Pi to lp */ }
if(! MLBytesToPut(lp, &bytes_left))
{ /* unable to get the remaining bytes to send from lp */ }
i++;
}
}