close
把此函數加入到程式碼中即可 (複製貼上):
程式碼:
int charArrayEquals(char a [], char b []){
程式碼:
int charArrayEquals(char a [], char b []){
int as = strlen(a);
int bs = strlen(b);
int i = 0;
if(as != bs){
return 0;
}
for(i = 0; i < as; i++){
if(a [i] != b [i]){
return 0;
}
}
return 1;
}
------------------------------------------------------------------------------
用法1:
------------------------------------------------------------------------------
用法1:
char c1 [] = "Hello Kitty";
char c2 [] = "Hello Kitty";
if( charArrayEquals( c1 , c2 ) ){
// 此處會被執行...
}
用法2:
char c1 [] = "Hello Kitty 1";
char c2 [] = "Hello Kitty 2";
if( charArrayEquals( c1 , c2 ) ){
// 此處不會被執行...
}
用法2:
char c1 [] = "Hello";
char c2 [] = "Hello Kitty";
if( charArrayEquals( c1 , c2 ) ){
// 此處不會被執行...
}
全站熱搜
留言列表