Compare equality of char[] in C

后端 未结 5 2180
抹茶落季
抹茶落季 2020-12-06 17:52

I have two variables:

char charTime[] = \"TIME\";
char buf[] = \"SOMETHINGELSE\";

I want to check if these two are equal... using ch

5条回答
  •  生来不讨喜
    2020-12-06 18:25

    In c you could use the strcmp function from string.h, it returns 0 if they are equal

    #include 
    
    if( !strcmp( charTime, buf ))
    

提交回复
热议问题