First, the basic concept of a string
1. Definition of a string
2. Basic operation of the string
Second, sequential storage structure of strings
1. Non-condensed storage of strings
Only one character is stored in a storage unit, and an element in the order table occupies a single storage unit. The concrete form is shown in Figure 1, set the string s= "How does You do".
2. String of condensed storage
Depending on the length of each machine word, as many characters as possible are stored in one word. If a word can store 4 characters, the condensed storage concrete form.
3. Byte storage of strings
Chain-type storage structure of three series
1 ///name:string2 ///Author:ja3 ///date:2015-3-94 5 6 7 ///block chain storage representation of a string8 #defineCHUNKSIZE 80//Block Size9typedefstructchunk{Ten CharCh[chunksize]; One structChunk *Next; A }chunk; -typedefstruct{ -Chunk *head, *tail;//head and tail pointers for strings the intCurlen;//the current length of the string - }lstring; - - ///Pattern Matching + intIndex (sstring s,sstring T, sstring pos) { -i = pos; j =1; + while(I <= s[0] && J <= t[0]){ A if(S[i] = = T[j]) {++i, ++j;}//continue to compare subsequent characters at Else{i = i-j +2; j=1}//The pointer backs back to start matching - } - if(J > t[0])returni-t[0]; - Else return 0; -}//IndexView CodeApplication of string: pattern matching
1. Traditional pattern matching
2.KMP algorithm
3/9/2015 2:48:24 PM
Data structure: string