I have an array declared in the global scope (outside the main() function) of size n, and inside the main() I need to assign it the first m (m < n) values. How do I approach this?
#include <iostream>
using namespace std;
int array[50];
int main()
{
array = {1,2,3,4,5}; //can not execute, error
return 0;
}
The error I am getting:
assigning to an array from an initializer list