I useCodeTo describe:
Typedef struct {int * Top; int * base; int stack_size;} sqstack; void initstack (sqstack ** s) {* s = (sqstack *) malloc (sizeof (sqstack); If (null! = * S) {(* s)-> Top = (int *) malloc (sizeof (INT); (* s)-> base = (* s) -> top; (* s)-> stack_size = 10 ;}} int main (INT argc, _ tchar * argv []) {sqstack * s = NULL; initstack (& S); If (null! = S) cout <s-> stack_size <Endl; retrun 0 ;}
In the main function, initstack (& S) removes the s address because if the s address is used instead of the s address, in the initstack function, S is equivalent to a local variable, assigning a value to a local variable does not affect the value of S in the main function. Besides, it is not possible to compile the variable using initstack (s. Here, using a second-level pointer is equivalent to passing the pointer address to the form parameter. Then, in the function, perform operations on the s address and change the s value in initstack, at the same time, it will be synchronized in the main function.