Hello.
I'm new in this forum and it looks a nice site for me to get helped and maybe help others .
I'm new on the C laguage and i want to know if i can do this with malloc:
Allocating a memory for an int array of n*sizeof(int) and and changing the array size just with changing the value of n, just like that example:
The compiler don't show any error and it works, but it seems to be not logic...Code:void main(){ int *array int n=5; //n is the size of the array. //allocate the memorie for the array array = (int *) malloc(n*sizeof(int)); n++; //when i change n value does the size of the array will change also ? array[5]=7; //giving a value to the new array square without realloc() or other thing... }
Thank you for helping.
Regards.