Hi all, I'm having trouble with arrays ( Yes I'm new to C )
Here is what I want to do in a nutshell:
#include <stdio.h>
main ()
{
printf("Please input the size of the array you want");
int arrsize;
scanf("%d",&arrsize);
int myarray [arrsize];
}
I can't do that so I've been experimenting with malloc and have come up with this:
int arrsize;
scanf("%d",&arrsize);
int *numptr;
numptr = (int *) malloc (arrsize);
This is where I'm stuck, now I've got this chunk of memory ( is it the right size? ) how can I make it so it acts as an array.
IE
myarray [0]
myarray [1]
...
myarray [arrsize]
Thanks in advance for any help.