i've try to compile this simple program, it will alloc a dyamic array and return it with a multiple of 5 in every location. but it doesn't work, it report me an error in the pointer.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
int n;
int i;
int* ptra;
scanf("%d", &n);
ptra = malloc(n*(sizeof(int)));
for(i=0; i<=n; i++){
ptra[i] = (5*(i+1));
printf("%d\n", ptra[i]);
}
return 0;
}
nintegers contains elements in the range from0ton - 1. Now take a look at your loop again, and think about that loop condition.