Reputation: 40641
In obj-c, do i have to initialise values eg pointers, or are they auto initialised to nil?
Eg:
- (void) myfunc {
EpgSparseEntry *onNow=nil, *next=nil, *later=nil;
}
Do i need the =nil , or can i assume that variables on the stack are initialised to zero/nil?
Thanks
Upvotes: 0
Views: 72
Reputation: 135558
Can i assume that variables on the stack are initialised to zero/nil?
No. Variables on the stack are not initialized so they contain random data.
That's different from an object's instance variables because all the memory an object occupies is zeroed out upon allocation.
Upvotes: 2