RWalib C Array Library User Guide > Array Initialization > alibRep
  

alibRep
Fills an array with some scalar value. The PV-WAVE API's for this routine are the MAKE_ARRAY Function, REPLICATE Function, and the vecOverArr Functions.
Prototypes
void alibRepb( wvlong n, UCHAR v, UCHAR *a )
void alibReps( wvlong n, short v, short *a )
void alibRepi( wvlong n, int v, int *a )
void alibRepl( wvlong n, wvlong v, wvlong *a )
void alibRepf( wvlong n, float v, float *a )
void alibRepd( wvlong n, double v, double *a )
void alibRepc( wvlong n, COMPLEX v, COMPLEX *a )
void alibRepz( wvlong n, DCOMPLEX v, DCOMPLEX *a )
Parameters
n — (Input) The number of elements in the array to be populated.
v — (Input) The scalar value with which to populate the array.
*a — (Input/Output) The array to be populated. On return, the first n elements of the array have been set equal to v.
Example
Here we create and print a 9-element array of 2's.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "alib.h"
void main() {
    wvlong n = 9;
    UCHAR    *b;
    b = (UCHAR*)malloc(n*sizeof(UCHAR));
    alibinit( NULL, NULL, NULL, NULL );
    alibRepb( n, 2, b );
    alibPrintArrayb( 1, 1, 1, n, b, NULL );
}
 
Output:
 
   2   2   2   2   2   2   2   2   2

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.