find middle point in c array -


I'm studying C programming. I want to get the middle point of the array without knowing about its length. The length is 6, the middle point was 4, but I have an error and I do not know what it is. Here is my code:

  int * a = (int *) malloc (sizeof (int) * n); Int i; For (i = 0; i   

Anyone can help you, thank you.

scanf ("% d", a [i])

  scanf ("% d", and a [i])   

and < Do not forget code> free memory when you have it. (It does not make any difference to such small applications, but if you get out of the learning phase and are entering real life then this is a good habit)

Anything else : sizeof (a) is the size of the indicator, not the size of the pointer point to allocate the memory (as is stated correctly in other answers).

Comments

Popular posts from this blog

c++ - Cmake produces file extensions in static library archives -

c# - Roxy file manager in MVC doesn't accept session path -

c# - XML - Serialize class - Some questions -