What is the proper function for comparing two C-style strings?

前端 未结 2 2020
北海茫月
北海茫月 2020-12-02 00:56

So I have a dilemma. I need to compare two C-style strings and I searched for the functions that would be the most appropiate:

memcmp   //Compare two blocks          


        
2条回答
  •  萌比男神i
    2020-12-02 01:11

    Both memcmp and strcmp will work fine. To use the former, you'll need to know the length of the shorter string in advance.

提交回复
热议问题