Hi, Everyone!
Does anyone know how to initialize an int array with a non-zero number?
int intArr[n1] = {x1}; // declaration and initialization
n1 can be any positive integer value and x1 can be any legitimate
value; number, char, pointer to another array, etc.. I believe you
don't need to specify all the elements in the list. That said, I
trust I will be corrected if I'm wrong
-- OR --
int intArr[n1]; // declaration
intArr[0] = x1; // initialization
It all depends on how far you want to go. You can give it a completer
list in the first example if you want. Or, you can use a for loop
that runs through the array index until it has filled the last
element, using the second statement inside the loop, substituting your
index variable for the zero and applying whatever number you
application feels is appropriate for the array.
You're welcome.
Ken Wilson
Amer. Dlx. Tele, Gary Moore LP, LP DC Classic w/P90s,
Jeff Beck Strat, Morgan OM Acoustic,
Rick 360/12, Std. Strat (MIM), Mesa 100 Nomad,
Mesa F-30
"Goodnight Austin, Texas, wherever you are."