String Pattern Matching

Source: Internet
Author: User

Question: a sequential structure is used to store strings and a string wildcard matching algorithm is compiled. The wildcard character is "?". It can match any character, such as pattern_index ("? Re "," there are ") returns 2. problem: stack around the variable "XX" was upted. A: the MSDN explanation is to read and write data outside the stack. The error is detected by the RTC1 compiler. I read more technical articles and found that when the project reaches a certain level, the programmer occupies a large amount of stacks. I also have a deep understanding. Because you have written a class, there is no error at runtime, but this error is easy to occur when adding member attributes without changing other methods. Therefore, I guess VS2005 (2008) limits the size of the stack internally. when the project is large enough, it will overflow.

Int pattern_index (SqString s, SqString t) {int I = 0, j = 0; while (I <s. length & j <t. length) {if (s. data [I] = t. data [j] | t. data [j] = '? ') {I ++; j ++;} else {I = I-j + 1; j = 0 ;}} if (j> = t. length) return (i-t.length); else return-1 ;}

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.