Hello,
After creating a 2D array and setting all the elements to 0 as follows:
How would one go about resetting the whole thing to contain all 0's again after filling the array up with characters? Thanks.Code:char 2darray[10][10] = 0
Hello,
After creating a 2D array and setting all the elements to 0 as follows:
How would one go about resetting the whole thing to contain all 0's again after filling the array up with characters? Thanks.Code:char 2darray[10][10] = 0
one way is loops. If you are doing it several times in the space of the program's code then put the loops in a function and just call the function, passing it the array you want to reset.
Notice elad said loops. When I do it I use two for loops, one nested within the other.Originally Posted by elad
I recently made a tic-tac-toe game and in the first version I filled the array I used for the board manually (a zillion commas)! What a drag that was. Then I figured out how to use loops. Feeling much better now!
Or maybe smaller
memset(2darray,0,10*10);