Home > Back-end >  C array dynamically allocated memory
C array dynamically allocated memory

Time:04-11

When encountered type n, then input n number need to be stored, then use the new dynamically allocated memory
int n=0;
Cin & gt;> N//input any data
Int * p=new int [n].
//use the
delete p;//release

Another way to use the vector
int n=0;
Cin & gt;> N//input any data
Vector V.
For (int I=0; I & lt; n; I++)
{
int temp=0;
Cin & gt;> Temp.
Valerie plame ush_back (temp);
}
//use the
  • Related