Automatic Array initialisation

This tip submitted by kedar on 2010-06-17 08:20:05. It has been viewed 6888 times.
Rating of 3.6 with 43 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!