Hello,
I am very new on C programing and have crossed the following error out of which I can get off:
"numbersort1.c", line 22: error #2028: expression must have a constant value
int numbers[size];
The code is:
#include <stdio.h>
Code:
int arraysize=0;
void bubblesortit(int *numbers){
int arrayposition=0;
int aux;
for(arrayposition=sizeof(numbers)/sizeof(int); arrayposition > -1; arrayposition--){
for(int x=0; x < (arrayposition - 1); x++){
if (numbers[x] > numbers[x+1]){
aux=numbers[x];
numbers[x]=numbers[x+1];
numbers[x+1]=aux;
}
}
}
}
main(const int size){
printf("Informe o numero de dados a inserir: ");
scanf("%d", &arraysize)a;
int numbers[arraysize];
for(int x=0; x < arraysize; x++){
printf("Informe o numero para a posicao %d: \n", x+1);
scanf("%d", &numbers[x]);
}
bubblesortit(numbers);
printf("Os valores informados foram\n");
for(int x=0; x < arraysize; x++){
printf("%d", numbers[x]);
}
}
Can anybody tell me how to set this array variable length to get this gig running?
Note: the intent here is to make it run, I am not looking for best practices as of now.
Thank you