While using my code in Visual Studio, I got a warning of dereferencing NULL pointer at p[i] = (int)i;
. Anybody knows how can I avoid this warning?
#define ARRAY_LEN 5
int main(void)
{
int* p;
p = (int*)malloc(ARRAY_LEN * sizeof(int));
for (size_t i = 0; i < ARRAY_LEN; i++)
{
p[i] = (int)i;
}
}