home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_03_06
/
3n06052a
< prev
next >
Wrap
Text File
|
1992-02-03
|
544b
|
35 lines
Listing 1
#include <stdio.h>
typedef int T;
/*
* Tcmp - compare two arrays of integers
*/
int Tcmp(const T *a1, const T *a2, size_t n)
{
int cmp;
size_t i;
for (i = 0; i < n; ++i)
if ((cmp = a1[i] - a2[i]) != 0)
return cmp;
return 0;
}
/*
* Sample calls to Tcmp...
*/
int a[] = {1, 2, 3, 4, -5};
int b[] = {1, 2, 3, 4, 4};
int main(void)
{
printf("a vs. b = %d\n", Tcmp(a, b, 4));
printf("a vs. b = %d\n", Tcmp(a, b, 5));
return 0;
}