The following code accepts as parameters 1) a pointer to an array of long values and 2) an int containing the number of elements in that array. The code loops through each element in the array, produces a string representing the corresponding long's value in binary, and prints the binary representation to stdout. It then returns an int.

The constant in the malloc (33) is there because the max length of the string is 32 (bits in a long) +'\0'.

What I would REALLY like to do is:
1) include (as an additional parameter) a pointer (char ***binrep??) declared in main 2) store (rather than print) each binary representation as a string in an array(referenced by the pointer passed from main) with the same index as it's long counterpart. For example, if element 0 of elearray is 7, then element 0 of binrep should be 111. The array (or rather, the pointers) are source of my problem.

I could then use the pointer (and pointer math) that was declared in main to access the elements of the array.

For the sake of furthering my understanding, I would prefer to use strictly pointers (NO []) because multiple levels of indirection is a real issue for me. I know there are many of you for whom this is a no-brainer, but I am really struggling trying to get the pointers to work.

Thanks

Code:
int conv2bin(long *elearray , int elemcount)
{
int i;
char *binrep=(char *)malloc(33*sizeof(char *));

    for (i=0;i<elemcount;++i)
    {

        _ltoa( *(elearray+i), binrep,2 );
        printf( "String of long int %ld (radix 2): %s\n", *(elearray+i), binrep);
    }

    return 0;
}