On Fri, May 19, 2000 at 07:36:36AM -0700, Michael Turley mentioned:
> Anyone got a C function which calculates the maximum
> value in an array that they'd like send to me?
Sounds like your homework ;)
int arraymax(int *array, int arraysize)
{
int i;
int max= (*array); //Max is first element in the array
for(i=1;i<arraysize;i++) { //From the 2nd element, to the end
if(*(array+i)<max) { //If what we are looking at is bigger than max...
max=*(array+i);
}
}
}
BTW, passing an array to a function gives the function a pointer to the
array to the first element in the array - C doesn't pass the whole struct
to it (like you can in C++).
Kate
--
"The fool must be beaten with a stick, for an intelligent person
the merest hint is sufficient" -- Zen Master Greg
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!