14 questions
0 votes
0 answers
82 views
Why I can't use printf() with variable 'i' as argument
` void DisplayFood(int*NumOfFood,int*Rno,char *Names[],int*Price,int*Quantity,char*mfg[],char*exp[]) { int i =0; for(i=0;i<*NumOfFood;i++) { printf("\n%-20d",Rno[i]); ...
0 votes
1 answer
97 views
C Pointer to arrays [duplicate]
I am learning pointers in C. When I declare : char c1[] ="hello"; c1[0] = c1[1]; printf("%s\n", c1); It prints out eello But when I do the following: char * c2="hello"; ...
0 votes
1 answer
59 views
I encountered some thing weird code in Dynamic memory allocation for 2D arrays in C++? please explain me what is this?
code:- p = new int *[5]; where p is a pointer & declared as int **P; Please explain me that why there is a * in between new and [5].
1 vote
1 answer
53 views
How to hand over values to a double-pointer and print the values out as if it would be an multidimensional array? (C)
I have following struct defined which I can not change: typedef struct _content { int length; char **lines; } content_t; I initialized it in the main function like that: struct _content ...
-1 votes
2 answers
448 views
how to find maximum value of UnsafeMutablePointer<Float> with bufferSize of data type UInt32 in swift?
I am new to swift and working on a project where i had to visualize audio waves! I am using EZAudio pod where to plot the waves on the screen a function UpdatePlot is used and in parameter a ...
14 votes
3 answers
2k views
NSPointerArray weird compaction
I have a weak NSPointerArray with some NSObject that has been released. Before calling compact what I see is: (lldb) po [currentArray count] 1 (lldb) po [currentArray pointerAtIndex:0] <nil> (...
2 votes
1 answer
3k views
How to add object to an NSPointerArray?
I want to store weak references in an NSPointerArray but I get an error: public var objectWithReloadFRC = NSPointerArray(options: NSPointerFunctionsWeakMemory) objectWithReloadFRC.addPointer(self) //...
1 vote
1 answer
100 views
How to grow 2d dynamically allocated string array in C++11 ?
So, I have been doing this question : Q. Write a program that lets users keep track of the last time they talked to each of their friends. Users should be able to add new friends (as many as they ...
0 votes
1 answer
3k views
Weak object array in Swift
I would like to create an object array as a property of another class in Swift, such as: class person{ var livingInHouse : house name : String } class house{ var personArray : [person] } My ...
0 votes
1 answer
652 views
NSPointerArray basics
I'm trying to get a hang of the NSPointerArray-class, and have a very specific question regarding table view cells. If I stored the pointer to a cell that is being pressed in a NSPointerArray, will I ...
241 votes
19 answers
71k views
How do I declare an array of weak references in Swift?
I'd like to store an array of weak references in Swift. The array itself should not be a weak reference - its elements should be. I think Cocoa NSPointerArray offers a non-typesafe version of this.
4 votes
2 answers
4k views
With NSPointerArray, how to iterate over opaque pointers?
I recently discovering these classes like NSMapTable and NSPointerArray, which work like the traditional collections, but also let you store weak references or plain old C pointers. Unfortunately it ...
2 votes
1 answer
481 views
NSMutableArray with [NSNull null] vs NSPointerArray
I am writing a chess program that stores all the pieces in an NSMutableArray with [NSNull null] representing empty spaces. I just found out about NSPointerArray and was wondering if I should switch ...
0 votes
1 answer
2k views
Accessing objects using NSPointerArray?
I have an NSPointerArray and in one of my methods, I want to access the objects stored in that NSPointerArray (as I have to use one of the object's properties). I don't want to create a new NSArray ...