Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!enuxha!hurwitz From: hurwitz@enuxha.eas.asu.edu (Roger A. Hurwitz) Newsgroups: comp.lang.c Subject: Generic array manipulation routine Keywords: C, arrays, pointers Message-ID: <2163@enuxha.eas.asu.edu> Date: 28 Jan 91 22:18:51 GMT Organization: Arizona State University, Tempe, AZ Lines: 23 Hello, Cpersons; I was hoping for some help on how to write a single C function for manipulating arrays, that can be called without change for arrays with elements of differing types. For example, the qsort() function I use in Borland's Turbo C seems to do this. Borland's qsort() has the following syntax; void qsort (void *base, size_t nelem, size_t width, int (*fcmp) (const void *, const void *)); Where _base_ is a pointer to the 0th element in the array, _nelem_ is the number of elements in the array, and _width_ is the size in bytes of each array element. Given these parameters, I suppose one could cast the void pointer to a char pointer and manipulate the elements byte-by-byte, but I was wondering if there is a "better" approach. Thanks in advance for any help, Roger Hurwitz hurwitz@enuxha.eas.asu.edu