We are working on ObjC, using NSArray, And suddenly using arrays of c. It's a little strange. Let's review it.
There are several methods to initialize the c array,
Initialize all members:
Int myArray [10] = {5, 5, 5, 5, 5, 5, 5, 5, 5 };
Set the default member to 0:
Int myArray [10] = {1, 2}; // initialize to 1, 2, 0, 0...
Initialize all Members as 0:
Int myArray [10] = {0}; // all elements 0
In C ++, empty initialization also sets all Members to 0:
Int myArray [10] ={}; // all elements 0 in C ++
If the declaration is static, all members are 0 by default. If you do not perform manual initialization.
Static int myArray [10]; // all elements 0
----------
Then I encountered a problem during development. If my array is a class member, I don't want to declare static, as shown below:
@ Private int touchInfos [2]; www.2cto.com
At this time, there is a problem with initialization, and the methods are not compiled.
[Cpp]
Int tis [2] = {0, 0 };
TouchInfos = tis;
[Cpp]
TouchInfos = {0, 0 };
Only values can be assigned one by one. one by one = _ =. Later, I thought of a solution using memset:
[Cpp]
Memset (touchInfos, 0, sizeof (touchInfos ));
Directly operate on the memory.