How to NULL arrays?
-
Following my first dumb question, I #include number[2]. Sorry about that! Being a newb is a bitch!!! :laugh: How do you NULL arrays? Is it ok to:
int numbers[10] = { 1, 23, 50, 2, NULL};
Or do I have to:int numbers[10] = {NULL};
and then assign values using a second statment! Apriciate the help! -
Following my first dumb question, I #include number[2]. Sorry about that! Being a newb is a bitch!!! :laugh: How do you NULL arrays? Is it ok to:
int numbers[10] = { 1, 23, 50, 2, NULL};
Or do I have to:int numbers[10] = {NULL};
and then assign values using a second statment! Apriciate the help! -
Following my first dumb question, I #include number[2]. Sorry about that! Being a newb is a bitch!!! :laugh: How do you NULL arrays? Is it ok to:
int numbers[10] = { 1, 23, 50, 2, NULL};
Or do I have to:int numbers[10] = {NULL};
and then assign values using a second statment! Apriciate the help!There is another thread that started just this morning, asking a very similar question about how to initialize arrays with zero values. See "Arrays!" by CreepingFeature which was posted at 8:58 this morning. There are many replies that will answer your questions on array initialization. Best Regards, Shawn
-
There is another thread that started just this morning, asking a very similar question about how to initialize arrays with zero values. See "Arrays!" by CreepingFeature which was posted at 8:58 this morning. There are many replies that will answer your questions on array initialization. Best Regards, Shawn
That was my thread!:omg:
-
That was my thread!:omg:
-
Ya don't say. Well I'm confused then. NULL stands for the number zero. If you really want to use NULL you have to write a for loop, I'm sorry to say. But that is rather pointless if it is zero anyway. Just follow the advice on the other thread. Shawn
As arrays of data are placed sequentically in memory (at least on unmanaged/non .Net programs), then you can use ZeroMemory to set the entire array area to zero. Alternatively, you can use ZeroMemory in conjuction with array indexes to clear certain sections. A few examples:
// Create an array
int nArray[20];// Clear the first three "slots"
ZeroMemory( &nArray[0], sizeof(int) * 3 );// Clear slots 10-15
ZeroMemory( &nArray[10], sizeof(int) * 5);// Clear the last slot
ZeroMemory( &nArray[19], sizeof(int) );Hope these will help you. -Antti Keskinen ---------------------------------------------- The definition of impossible is strictly dependant on what we think is possible.