Hi, this is my first post here, and I'm sure I'll be back for more later!
I'm learning Obj-C, and stumbled on some C code that I find useful, but as I'm a totally new to this, I find it a little bit hard understanding about pointers and types.
The idea is to call the makeChar-method from the main code, get it processed, and then returned to the main. Basically myChar gets filled with 0 and 1's.
The next step is to send along some parameters for different situations, so that's why it's a method.
It's a mix of C and Obj-C code, but I hope it's common enough for you geniuses to see what's wrong here.
The code is kinda pseudo, since the real code is just longer, and gets the same errors.
Inside the method, I can read myChar[5] with no problem, but I can't get it out of there.
I've searched for the errors for several hours, but couldn't find an answer to what I'm doing wrong here.Code:int myChar = [self makeChar]; int char5 = myChar[5]; // Error: subscripted value is neither array nor pointer -(unsigned char)makeChar { unsigned char *myChar = (unsigned char *)malloc(50); myChar[5] = 1; return myChar; // Warning: return makes integer from pointer without a cast }
Thank you in advance for any help!