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)
and it's terribly bulky.Code:int cx = 0; int cy = 0; while (cy != 3) { array[cx][cy] = 1; if (cx == 2) { cx = 1; cy++; } else { cx++; } }
Also, if you want to pass an array to a function, do you do something like
or justCode:int main() { int *ptr; ptr = array; function(ptr); ... int function(int ptr)
?Code:int main() { function(array) ... function(int *array)



LinkBack URL
About LinkBacks



Want to add some