objective c - How to reset C array so all elements are 0 -


if have int somearray[100] contains items in various elements, how can reset them 0?

basic question, know, use objective-c arrays purpose i'm storing numbers , want deal "old school."

you need set each element value want:

for (int = 0; < 100; ++i)     somearray[i] = 0; 

for specific case of integers , value 0, can make use of fact bitwise representation known (all bits 0), , can use memset:

memset(somearray, 0, sizeof(somearray)); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

asp.net mvc - Implementing normal user/pass, Twitter & Facebook auth -