Static vaiable and dyamic memory allocation

  1. first of all as we have used static variable input to keep a check on words extracted but in the function defination first line we have initialised with null so will the input variable not get initialised with null each time function is called
  2. if i input variable n as the size of variable then initialise array as arr[n],then this memory is also allocated at run time,isn’t it?

hi @J20APPPP0006 if the variable gets initialised with NULL everytime, then we will be stuck on the first token itself.
actually this is not the way to declare an array at all, because the only way to do dynamic memory allocation is using the new operator. using this notation static memory allocation will be used. the reason this is not recommended is that static allocation is done during compilation. and so it must be a constant value.

as i m saying that only that if variable get initialised everytime ,it will stuck but this is done in the video in which string tokenisation is implemented . In the first line of the defination of function initialisation is done

at 4:10 time in the video

@J20APPPP0006 it is a static variable as you pointed out so it not initialised everytime. Static variables when used inside function are initialized only once, and then they hold there value even through function calls. These static variables are stored on static storage area , not in stack.