Comparing two arrays in C, element by element

后端 未结 5 951
孤城傲影
孤城傲影 2020-12-20 20:30

I have been cracking my head at achieving something very simple in C in order to make my one of the programs (not written by me) in our computational physics project more dy

5条回答
  •  悲&欢浪女
    2020-12-20 21:08

    If it must be at compile time, there is nothing in the standard that provides for a repeating macro like that. As in another (question), for bounded N, you can prepare N macros that expand to your desired comparison.

    While yet another alternative is memcmp

    memcmp( data, data2, array_len_in_bytes );
    

    reference

提交回复
热议问题