Duration of variables is different depending on where they are define and which storage class is applied to them. Look at this example code:
*** File mySource.c
int var1;
static int var2;
void function1 (void) {
int var3;
static int var4;
......
return;
}
*** End of mySource.c
Variables declared in this example have this characteristics:
- Variables declared in a block (e.g. var3) have the same lifetime as the block (i.e. are released when exiting the block)
- Variables declared in a block and assigned static storage class (e.g. var4) are allocated the first time the block is run and never released. They can be accessed only within the block they are declared into
- Variables declared at module level (e.g. var1) are allocated at program start and never released. They can be accessed from any function within the module and from functions in another module if declared there with the extern keyword
- Assigning them to the static storage class (e.g. var2) limits their scope to within the module only (i.e. they cannot be acessed from outside the module)
So, in your code pText is stable for all program life.