#define_crt_secure_no_warnings#include<stdlib.h>#include<string.h>#include<stdio.h>//the third memory model for two auxiliary pointer variables to dig a string//pointers do function argumentsintSpitString4 (Char*BUF1,CharCCharMYP3,int*count)//**pp Level two pointer input{ Char*p=null, *ptmp =NULL; intTmpcount =0; intLen; Char**myp=NULL; //1 P and ptmp initializationp =buf1; Ptmp=buf1; //the first time to find Count Do { //2 Retrieving a position that matches the condition P moves back to form a difference digging stringp =STRCHR (P, c); if(P! =NULL) { if(P-ptmp >0) {Tmpcount++; //3 re-enable p and ptmp to reach the next search conditionptmp = p = p +1; } } Else { Break; } } while(*p!=' /'); *count =Tmpcount; //accurately allocate memory based on how many rowsMyp= (Char**)malloc(Tmpcount *sizeof(Char*)); if(myp==NULL) { return-1; } /////////////////////////////////////////////////////////Tmpcount=0; //1 P and ptmp initializationp =buf1; Ptmp=buf1; Do { //2 Retrieving a position that matches the condition P moves back to form a difference digging stringp =STRCHR (P, c); if(P! =NULL) { if(P-ptmp >0) {len=p-ptmp+1; Myp[tmpcount]=(Char*)malloc(Len *sizeof(Char)); if(myp==NULL) { return-1; } strncpy (Myp[tmpcount],ptmp,p-ptmp); Myp[tmpcount][p-ptmp]=' /'; Tmpcount++; //3 re-enable p and ptmp to reach the next search conditionptmp = p = p +1; } } Else { Break; } } while(*p!=' /'); //*count = Tmpcount;*MYP3 = MYP;//MYP3 is a value of level two pointer address return 0;}intMain () {inti; intret=0 ; Char*p1="ABCDEF,AAA,EEEEE,FFFFFF,A3A3A3,"; Chartmp=','; Char**p=NULL; intncount; RET=spitstring4 (p1,tmp,&p,&ncount); if(ret!=0) {printf ("Fun spiltstring () err:%d \ n", ret); returnret; } for(i=0; i<ncount;i++) {printf ("%s \ n", P[i]); } for(i=0; i<ncount;i++) { Free(P[i]); } Free(P); printf ("%d \ n", ncount); printf ("hello...\n"); System ("Pause");}
C Raise _day03_ Two auxiliary pointer variable dig string (reinforcement 3)