The XDR library provides a primitive, xdr_vector(), for fixed-length arrays, shown in Example A-11.
#define NLEN 255 /* machine names must be < 256 chars */ #define NGRPS 20 /* user belongs to exactly 20 groups */ struct netuser { char *nu_machinename; int nu_uid; int nu_gids[NGRPS]; }; bool_t xdr_netuser(xdrs, nup) XDR *xdrs; struct netuser *nup; { int i; if (!xdr_string(xdrs, &nup->nu_machinename, NLEN)) return(FALSE); if (!xdr_int(xdrs, &nup->nu_uid)) return(FALSE); if (!xdr_vector(xdrs, nup->nu_gids, NGRPS, sizeof(int), xdr_int)) return(FALSE); return(TRUE); }