I am definitely new to the C game, and would love some help with the following code snippet:
#include <stdio.h>
int main() {
int cases;
scanf("%d", &cases);
printf("%d", cases);
int i;
int *heights;
for(i=0; i<cases; i++){
scanf("%d", &heights[i]);
}
return 0;
}
I understand that it segfaults because I'm giving scanf a NULL pointer, so is there any way to allow scanf to feed values into this pointer? Or is there a better method to get a variable number of arguments from stdin which I'm missing entirely?