Time:10-11
CodePudding user response:
this several array function really don't have to do a DLL that trouble, what language to write a line,
# include & lt; stdio.h> #include Char string [80]. Char seps1 [3]. Char seps2 [3]. Char * token; Char * zzstrtok (Char * string, Const char * control1,//continuous emerged as empty token between Const char * control2//continuous emerged as intermediate no empty token ) {Unsigned char * STR. Const unsigned char * ctrl1=control1; Const unsigned char * ctrl2=control2; Unsigned char map1 [32], map2 [32]. The static char * nextoken; The static char flag=0; Unsigned char c; Int L; Memset (map1, 0, 32); Memset (map2, 0, 32); Do {Map1 [3] * ctrl1 & gt; & gt; |=(1 & lt; <(* ctrl1 & amp; 7)); } while (* ctrl1 + +); Do {Map2 [3] * ctrl2 & gt; & gt; |=(1 & lt; <(* ctrl2 & amp; 7)); } while (* ctrl2 + +); If (string) {If (control2 [0]) {L=strlen (string); While (1) {C=string [L - 1); If (map2 [c & gt; & gt; 3) & amp; (1 & lt; <(c & amp; 7))) {L -; String [L]=0; } the else break; } } If (control1 [0]) {L=strlen (string); C=string [L - 1); If (map1 [c & gt; & gt; 3) & amp; (1 & lt; <(c & amp; 7))) {String [L]=control1 [0]; String [m + 1)=0; } } STR=string; } The else STR=nextoken; String=STR; While (1) {If (0==flag) {if (! * STR) break; If (map1 [* STR & gt; & gt; 3) & amp; (1 & lt; <(* STR & amp; 7))) {* STR=0; Str++; break; } else if (map2 [* STR & gt; & gt; 3) & amp; (1 & lt; <(* STR & amp; 7))) {String++; Str++; } else {Flag=1; Str++; } {} else if (1==flag) if (! * STR) break; If (map1 [* STR & gt; & gt; 3) & amp; (1 & lt; <(* STR & amp; 7))) {* STR=0; Str++; Flag=0; break; } else if (map2 [* STR & gt; & gt; 3) & amp; (1 & lt; <(* STR & amp; 7))) {* STR=0; Str++; Flag=2; break; } the else str++; } else {//2==flag if (! * STR) return NULL; If (map1 [* STR & gt; & gt; 3) & amp; (1 & lt; <(* STR & amp; 7))) {Str++; String=STR; Flag=0; } else if (map2 [* STR & gt; & gt; 3) & amp; (1 & lt; <(* STR & amp; 7))) {Str++; String=STR; } else {String=STR; Str++; Flag=1; } } } Nextoken=STR; If (string==STR) return NULL; The else return a string; } Void main () {Strcpy (string, "A \ \ tstring \ t tof,, tokens \ n \ nand more tokens,"); Strcpy (seps1, "\ n"); Strcpy (seps2, "\ t"); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "1234 | LIYI | China | | 010 | 201110260000 OK"); Strcpy (seps1, "|"); Strcpy (seps2, ""); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "1234 | LIYI | | 010 | 201110260000 | OK"); Strcpy (seps1, ""); Strcpy (seps2, "|"); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "1234 | LIYI | | 010 | 201110260000 | OK"); Strcpy (seps1, "|"); Strcpy (seps2, ""); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "a"); Strcpy (seps1, ", "); Strcpy (seps2, ""); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "a, b"); Strcpy (seps1, ", "); Strcpy (seps2, ""); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "a,, b"); Strcpy (seps1, ", "); Strcpy (seps2, ""); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } Strcpy (string, "and a"); Strcpy (seps1, ", "); Strcpy (seps2, ""); Printf (" \ n \ [% s] nTokens: \ n ", string); Token=zzstrtok (string, seps1 seps2); While (token!=NULL) {Printf (" & lt; % s>" The token); Token=zzstrtok (NULL, seps1 seps2); } nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
Page link:https//www.codepudding.com/Softwareengineering/61541.html