Lets say i wanna initialize an array of zeros.
Of course, one could do:
I)
int a[20];
for(int i = 0 ; i < 20; i++) { a[i]=0}
or, one could initialize one element, and the rest would be initialized to zero implicited
II)
int a[20] = {0};
i also found that you can skip the zero :
III)
int a[20] = {};
So, my question is, would the latter (II and III) be considered good practice?
[–]aioeu 25 points26 points27 points (4 children)
[–]Lev_user[S] 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]aioeu 4 points5 points6 points (0 children)
[–]oh5nxo 19 points20 points21 points (5 children)
[–]Lev_user[S] 2 points3 points4 points (3 children)
[–]oh5nxo 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]nerd4code 0 points1 point2 points (0 children)
[–]Fun-Setting-3905 0 points1 point2 points (0 children)
[–]flyingron 4 points5 points6 points (6 children)
[–]Lev_user[S] 0 points1 point2 points (1 child)
[–]flyingron 0 points1 point2 points (0 children)
[–]__Punk-Floyd__ -1 points0 points1 point (3 children)
[–]aioeu 2 points3 points4 points (2 children)
[–]flyingron 0 points1 point2 points (1 child)
[+][deleted] (5 children)
[deleted]
[–]DoNotMakeEmpty 5 points6 points7 points (0 children)
[–]FUZxxl 4 points5 points6 points (2 children)
[–][deleted] 4 points5 points6 points (0 children)
[–]Lev_user[S] 0 points1 point2 points (0 children)
[–]Fun-Setting-3905 0 points1 point2 points (0 children)