functions calling from main method objective c -
functions calling from main method objective c -
here need write function called main method integer array parameter please give me example.
in below illustration parameter int type.
note : please tell right way or not...
#import <foundation/foundation.h> void displayit (int); int main (int argc, const char * argv[]) { @autoreleasepool { int i; (i=0; i<5; i++) { displayit( ); } } homecoming 0; } void displayit (int i) { int y = 0; y += i; nslog (@"y + = %i", y); }
thanks in advance....
i tried out these, please check.
#import <foundation/foundation.h> void displayit (int array[], int len); int main (int argc, const char * argv[]) { @autoreleasepool { int array[]={1,2,3}; displayit( array, 3 ); } homecoming 0; } void displayit (int array[], int len) { for(int i=0;i<len;i++){ nslog(@"display %d : %d",i,array[i]); } }
the out set is:
2014-10-30 14:09:32.017 ostest[32541:77397] display 0 : 1 2014-10-30 14:09:32.018 ostest[32541:77397] display 1 : 2 2014-10-30 14:09:32.018 ostest[32541:77397] display 2 : 3 programme ended exit code: 0
i used parameter len
avoid boundary beyond.
if array global, static, or automatic variable (int array[10];), sizeof(array)/sizeof(array[0]) works. quoted question
objective-c function main-method
Comments
Post a Comment