黑马程序员技术交流社区

标题: C语言库函数strcmp [打印本页]

作者: pojian    时间: 2016-3-10 14:16
标题: C语言库函数strcmp
以下与库函数strcmp(char *s, chat *t)的功能相等的程序段是()。
A. strcmp1( char *s, chat *t)
{
    for ( ;*s++==*t++ ;)
    {
        if (*s=='\0')
        {
            return 0;
        }
    }
    return (*s-*t);
}
B. strcmp2( char *s, char *t)
{
    for ( ;*s++==*t++ ;)
    {
        if (!*s)
        {
            return 0;
        }
    }
    return  (*s-*t);
}
    C. strcmp3( char *s, char *t)
    {
        for ( ;*t==*s ;)
        {
            if (!*t)
            {
                return 0;
            }
            t++;
            s++;
        }
        return (*s-*t);
    }
    D. strcmp4( char *s, char *t)
    {
        for( ;*s==*t;s++,t++)
        {
            if (!*s)
            {
                return 0;
            }
        }
        return (*t-*s);
    }
   








欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2