I'm currently learning C
and wanted to write a program that takes a number ganzeZahl
to determine array length.
Then you have to input the numbers being stored in that array of size n
and after that it's supposed to do a selection sort (which I cut out here, because my program doesn't even reach to that part).
I can't get past the while loop whenever I try to run it. It compiles fine.
It never reaches the printf("!!!--------!!!");
//this part isn't reached for some reason? test5.
#include<stdio.h>
int main() {
int ganzeZahl;
scanf("%d", &ganzeZahl);
//printf("ganze Zahl ist: %d\n", ganzeZahl); //test
int array[ganzeZahl];
int i = 0;
for(int z = 0; z < ganzeZahl; z++) {
printf("%d\n", array[z]);
}
while(i<ganzeZahl) {
//printf("!!!hier!!!\n"); //test2
scanf("%d", &array[i]);
//printf("zahl gescannt!\n"); //test 3
i++;
//printf("i erhöht!\n"); //test 4
}
printf("!!!--------!!!"); //this part isn't reached for some reason? test5
//selection sort here
//[...]
return 0;
}