Okay, I think this code should work:
It works for me, I'm using MS Visual C++ 6. I'm not sure what you're using; you have used C-style casts so I suppose you're using C. I've tried to stick to what you used, with corrections.Code:#include <iostream.h> #include <stdlib.h> #include <time.h> int* my(int* ta, int an) { int* temp; temp = ta; for(int j=0;j<an;j++) { if(*ta < *temp) temp = ta; ta++; } return(temp); } int main() { int ta[10]; int *sv; srand((unsigned)time(NULL)); //Initialise ta[] array with random integers for(int j=0; j<10; j++) { ta[j]=rand(); cout << "ta[" << j << "] = " << ta[j] << endl; } sv = my(ta, sizeof(ta)/sizeof(ta[0])); cout<< " Smallest numbers is: " << *sv << endl << endl; return(0); }
(I've edited this message to use j instead of i as a counter, because the i in square brackets is italic tags)
[Edited by HarryW on 06-20-2000 at 02:07 PM]




Reply With Quote