C + + Judgment string size function __ function

Source: Internet
Author: User
First determine whether the size is the same, if not the same, return false.

If, again, compare, if you find a difference, return false. Returns true until the last one is checked;

BOOL Compare (const char* p1, const char* p2)
{
	int len = strlen (p1);  If the English state of a character size of 1 such as song, then Len 4
	if (len!= strlen (p2))//If the Chinese state of a Chinese character of 3, such as song, then Len 3
	{return
		false ;
	} else {for
		(int i = 0, i < len; i++) {
			if (* (p1+i)!= * (P2+i)) {return
				false;
			}
		}
		return true;
	}


Related Article

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.