Automatic Array initialisation

This tip submitted by kedar on 2010-06-17 08:20:05. It has been viewed 10121 times.
Rating of 4.7 with 74 votes

If you want to initialise each array element to ZERO, you would code like this:


You can also initialise the entire array without using the for loop.

For example:
int a[10]={0};

Nice and convenient!

More tips

Help your fellow programmers! Add a tip!