I'm trying to code an algorithm in c++ to sort random numbers. I've coded a function to generate the random numbers that take as parameters a variable for the number of integers and an array to store the random numbers but when I declare the array there's an error telling me that structured binding declaration cannot have a type long int and that there's an empty structured binding declaration and also that expected initializer before 'Nb_alea' that is the name of the function. I don't understand quite well the meaning of those errors. Could you explain, please! Here is the code :
int main()
{
cout << "Hello world!"<< endl;
long x;
cout<<"Veuillez saisir le nombre d'entiers vous souhaitez trier par ordre décroissant : "<<endl;
cin>>x;
long tab_nb_alea[x];
int y;
cout<<"1-tri rapide, 2-tri fusion, 3-tri par tas"<<endl;
cin>>y;
string chemin_acces;
cout<<"Veuillez rentrer le chemin d'accès du dossier vers lequel vous souhaitez creer et enregistrer le ficher texte : "<<endl;
cin>>chemin_acces;
Nb_alea(x, tab_nb_alea);
}
long[] Nb_alea(long x, long tab_nb_alea[])
{
int max;
max=100;
if(x==0)
{
cout<<"Probleme, vous devez selectionner un nb superieur a 0!"<<endl;
}else if(x==1)
{
tab_nb_alea[x]=rand()%max;
return tab_nb_alea;
}else if(x>1)
{
srand(time(0));
tab_nb_alea[x]=rand()%max;
return Nb_alea(x-1, tab_nb_alea);
}
}
||=== Build: Release in ProjetC++037_REVEILLAUD_Elie_Juin_2021 (compiler: GNU GCC Compiler) ===| C:\Users\elie\Documents\c\exo_listes_chainee\ProjetC++037_REVEILLAUD_Elie_Juin_2021\main.cpp|23|warning: structured bindings only available with -std=c++17 or -std=gnu++17| C:\Users\elie\Documents\c\exo_listes_chainee\ProjetC++037_REVEILLAUD_Elie_Juin_2021\main.cpp|23|error: structured binding declaration cannot have type 'long int'| C:\Users\elie\Documents\c\exo_listes_chainee\ProjetC++037_REVEILLAUD_Elie_Juin_2021\main.cpp|23|note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'| C:\Users\elie\Documents\c\exo_listes_chainee\ProjetC++037_REVEILLAUD_Elie_Juin_2021\main.cpp|23|error: empty structured binding declaration| C:\Users\elie\Documents\c\exo_listes_chainee\ProjetC++037_REVEILLAUD_Elie_Juin_2021\main.cpp|23|error: expected initializer before 'Nb_alea'| ||=== Build failed: 3 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|