Is there a way to set all the elements of an array to a certain number, say 1, without doing something like
Code:
hello[] = (1, 1, 1, 1, 1, 1, 1, 1, 1...)
?
Currently I'm using (for a 3 by 3 array)
Code:
int cx = 0;
int cy = 0;
while (cy != 3)
{
array[cx][cy] = 1;
if (cx == 2)
{
cx = 1;
cy++;
}
else
{
cx++;
}
}
and it's terribly bulky.
Also, if you want to pass an array to a function, do you do something like
Code:
int main()
{
int *ptr;
ptr = array;
function(ptr);
...
int function(int ptr)
or just
Code:
int main()
{
function(array)
...
function(int *array)
?