Hi Im currently building an iPad app. I was using the memset() as below but every tine it runs I get a bad access error?
arrayPointer = malloc(sizeof(int) * size);
memset(arrayPointer, 0, sizeof(int)* size); //sets all the values in the array to 0
Cheers
You could use
calloc()it basically does the same asmalloc()but also sets all bits to 0 in the allocated memory. It is also suited well for array initializations. For your example:EDIT: You should consider inspecting the returned pointer.
NULLwill be returned, when your memory allocation was erroneous.