objective c - Function returning an array in ObjC for iPhone -


hello trying make function return array! going wrong here?

-(char[10])print01:(int)int11{ //error: declared method returning array     char arrayt[10];      for(int i=0;i<8;i++)     {         if ((int1-n1)>=0){             arrayt[i]='1';             int1-=n1;         }         else              arrayt[i]= '0';         n1=n1/2;     }      return arrayt[]; // incompatible types in return } 

and want call that:

char array1[10] = [self print01:(int)int1]; //error: invalid initializer 

any suggestions please?

the best approach using nsarray (of objects of course, i'm assuming above code simplified sample, can use nsnumber). alternatively, return pointer array, common in c c (and objective c extension) cannot return array. unfortunately, require allocating memory array , using manual memory management, (malloc/free) depending on lifecycle of array, can anywhere nuisance awful. recommendation taking char *dest parameter, , inserting chars array dest[i]


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -