I'm writing some program and i was wondering is there any way to change ALL numbers in array at once for example when you initialise array you can write

int array[10]={0};

is there anything like that i can use in the middle of the program.

I have googled for it but didn't managed to find anything that is shorter than for loop.

any information is welcomed.

C++ reference: <algorithm>. The generate and fill families are probably what you want. You can also use the inherited C functions in some cases, but for C++ they're more likely to be dangerous than anything.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.