Hello, I'm doing a sort program in c but I'm having difficulties. How or where, and what I put for the user to enter the size of the array as well as its elements.
I tried this way:
#include <stdio.h>
int main(){
int num[];
int tam, l;
int i, j, min, aux;
printf("Digite o tamanho do array: ");
scanf("%d", tam);
printf("Digite o array: ");
scanf("%d", num[]);
for (i = 0; i < (tam-1); i++){
min = i;
for (j = (i+1); j < tam; j++) {
if(num[j] < num[min]) {
min = j;
}
}
if (i != min) {
aux = num[i];
num[i] = num[min];
num[min] = aux;
}
printf("\n");
}
}
But when you type something already closes the program, does anyone know how to fix it?