This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
MathLink C Function


int MLPutByteArray(MLINK link, unsigned char *a, int *dims, char **heads, int d)
puts an array of integers in the range 0-255 to the MathLink connection specified by link to form a depth d array with dimensions dims.
  • The array a must be laid out in memory like a C array declared explicitly as unsigned char a[m][n]....
  • If heads is given as NULL, the array will be assumed to have head List at every level.
  • The length of the array at level i is taken to be dims[i].
  • MLPutByteArray() returns 0 in the event of an error, and a nonzero value otherwise.
  • Use MLError() to retrieve the error code if MLPutByteArray() fails.
  • MLPutByteArray() is declared in the MathLink header file mathlink.h.
#include "mathlink.h"

/* send a list of integers in the range 0-255 to a link */

void f(MLINK lp)
    unsigned char array[10][5][3][4];
    long dims[4];
    int i;

    for(i = 0; i < 600; i++)
        *((unsigned char *)array + i) = i;

    dims[0] = 10;
    dims[1] = 5;
    dims[2] = 3;
    dims[3] = 4;

    if(! MLPutByteArray(lp, (unsigned char *)array, (long *)dims, (char **)0, 4))
        { /* unable to send array of integers to lp */ }