I have been stuck on a simple problem for 10 hours, can someone please help
all im doing is the following.
I have a function that is being passed a pointer.
The pointer points to an int array.
I wrote a function to find the largest value. For some reason it is failing the condition after it runs 6 times. The array is 10 long therefore it should run 10 times. Can someone please help. I have to write it this was, so yes im sure there are easier way but i need to write it the way i have it. For some other odd reason if i change 10 to 12 it works. but the array is not 12 long its 10 long.
Im sorry its so messy i tried to clean it up but the forum editor will not coperateCode://*a points to &myarray[0] inside of main. Then a is passed to the //function //&a+10 should of failed when it reaches address 9 of the array for(;a<&a+10;a++){ printf("This is the address of a right now [%p]\n",a);//just for //test,prints the address im currently at. count++;//count just keeps track of how man times the loop goes off if (*a>*largest){ *largest=*a; } } a=&a-10; for(;a<&a+10;a++){ if(*a<*largest&&*second_largest<*a){ *second_largest=*a; } }
Thanks for the help