这个功能有什么作用?

mik*_*ike 4 c pointers loops

int mystery( const char *s1, const char *s2 ) {
  for( ; *s1 != '\0' && *s2 != '\0'; s1++, s2++ ) {
    if( *s1 != *s2 ) {
      return 0;
    } //end if
  } //end for
  return 1;
}
Run Code Online (Sandbox Code Playgroud)

我知道它有输入错误,但这正是它的原因.谢谢你们,我需要它也运行,我已经添加了变量声明,但我得到编译器错误说

在功能上,'或';' 在'{'之前`int main()':
error: a function-definition is not allowed here before '{' token
error: expected

Kla*_*sen 11

它比较两个字符串,1如果字符串1以字符串2开头则返回,反之亦然0.

  • 那不对."Foo"和"FooBar"将评估为1. (5认同)
  • @sharth,很好看.我已经更新了我的答案. (2认同)