How to compare whether two-dimensional arrays are equal-reply to the question "Aladdin"

Source: Internet
Author: User
One sentence: Use comparemem to compare memory.
{Compare static array} procedure tform1.button1click (Sender: tobject); var arr1: array [0 .. 3] of ansichar; arr2: array [0 .. 3] of byte; begin arr1 [0]: = 'a'; arr1 [1]: = 'B'; arr1 [2]: = 'C '; arr1 [3]: = 'D'; arr2 [0]: = 65; arr2 [1]: = 66; arr2 [2]: = 67; arr2 [3]: = 68; If comparemem (@ arr1, @ arr2, sizeof (arr1) Then showmessage ('data in arr1 and arr2 is the same '); end; {compare dynamic array} procedure tform1.button2click (Sender: tobject); var arr1: array of ansichar; arr2: array of byte; begin setlength (arr1, 4); setlength (arr2, 4); arr1 [0]: = 'a'; arr1 [1]: = 'B'; arr1 [2]: = 'C'; arr1 [3]: = 'D'; arr2 [0]: = 65; arr2 [1]: = 66; arr2 [2]: = 67; arr2 [3]: = 68; if comparemem (arr1, arr2, sizeof (arr1) Then showmessage ('data in arr1 and arr2 is the same '); end; {multi-dimensional array is the same} procedure tform1.button3click (Sender: tobject); var arr1: array [0 .. 1, 0 .. 1] of ansichar; arr2: array [0 .. 1, 0 .. 1] of byte; begin arr1 []: = 'a'; arr1 []: = 'B'; arr1 []: = 'C '; arr1 []: = 'D'; arr2 []: = 65; arr2 []: = 66; arr2 []: = 67; arr2 []: = 68; If comparemem (@ arr1, @ arr2, sizeof (arr1) Then showmessage ('data in arr1 and arr2 is the same '); end;
 
  
 

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.