I try as follows:
int main() { int n; int i; printf("Enter elements", n); scanf("%d", &n); int* a = malloc(n * sizeof(int)); for (i = 0; i < n; i++) { printf("a[%d] = ", i); scanf("%d", &a[i]); } for (i = 0; i < n; i++) printf("%d ", a[i]); getch(); return 0; } The compiler gives the following error:
Error 2 error C2440: 'initializing': cannot convert from 'void *' to 'int *'