Possible Duplicate:
array in objective c
i have doubt about how to find the length of array.....
my code is
#import <Foundation/Foundation.h>
void myFunction(int i, int*anBray);
int main(int argc, const char * argv[])
{
int anBray[] = {0,5, 89, 34,9,189,9,18,99,1899,1899,18,99,189, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,89, 34,2,600,-2,0};
int i;
NSLog (@"Input:");
for (i=0; i<sizeof(anBray)/sizeof(int); i++)
NSLog(@ " anBray[%i]= %i ",i,anBray[i]);
NSLog (@"Output");
myFunction(i,anBray);
return 0;
}
void myFunction(int i, int*anBray) {
for ( i=0; i<anBray; i++) {
if ( anBray[i] == 0) {
anBray[i] = anBray[i+1] - anBray[i];
} else {
anBray[i] = anBray[i] - anBray[i];
anBray[i] = anBray[i+1] - anBray[i];
}
NSLog(@ " anBray[%i]= %i",i,anBray[i]);
}
}
in the function "void myFunction" it works but it gives garbage value too.how can it makes properly works? plz help...