Automatic Array initialisation

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



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

for(i=0;i


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!