There's No Spoon Randomness
Computers are deterministic. They must be, otherwise they couldn't operate. 1 + 1 must be always 2. It cannot be 1 or 3 some times.
The computer has no idea about a random number. What you can generate easily is a "pseudo-random" number. Pseudo, as it's not really random. In fact, easily reproducible (as you've seen yourself).
These pseudo-random numbers make up sequences. They continue forever, there doesn't seem to be any logic for the next number to be generated, nevertheless, these sequences are fully deterministic.
The upside is that there are many such sequences. And by selecting one or the other you may seem to be able to generate "truly" random numbers.
How to select which sequence to use? That's what the seeds are used for.
You can see in your code, you use the seed 0.
If you want to use a (probably) different sequence every time, you can use a different seed every time. A typical solution is to take the current time and use the number of seconds or ticks as shown here.
The Code
#include <chrono>
#include <bits/stdc++.h>
using namespace std;
//Shuffle array
void shuffle_array(int arr[], int n)
{
//Obtaining a time-based seed
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
//Shuffling our array
shuffle(arr, arr + n, default_random_engine(seed));
//Printing our array
for(int i=0; i<n; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int a[5];
for(int assign=0; assign<5; assign++)
{//This for-loop assigns each slot in the 'a' array its own number
a[assign] = assign;
}
int n = sizeof(a) / sizeof(a[0]);
shuffle_array(a, n);
return 0;
}
Update
I was bored at work waiting for a build to finish so I looked at this once again.
It seems like shuffle() is part of the c++ standard. There's also an example there (see the bottom of the page) that uses std::vector, instead of a raw array.