一个C语言问题,用一个函数实现两个字符串的比较。

用一个函数实现两个字符串的比较,即自己写一个strcmp函数,函数原型为:
int strcmp(char *p1,char *p2);

要求:

两个串相等时,返回0
p1>p2时,返回值>0
p1<p2时,返回值<0

请求一个流程图,还有最后实际测试效果,两个串分别三种情况下最后显示是怎么样的。

谢谢大佬们了!

供参考:

#include <iostream>
#include <cstring>
using namespace std;

int My_strcmp(char *str1,char *str2)    //声明两个字符指针变量str1和str2
{
    while(*str1 == *str2 && *str1!='\0')
    {
          str1++;
          str2++; 
    }
    if(*str1 == '\0' && *str2 == '\0') return 0;
    else  return  (*str1-*str2);// 返回字符串比较结果
}


int main()
{
    char s1[50], s2[50];
    int r;
    cout<<"please input the first string: ";
    cin>>s1;
    cout<<"please input the second string: ";
    cin>>s2;
    r=My_strcmp(s1,s2);
    cout<<r<<endl;
    if (r>0)
        cout<<s1<<" is larger!"<<endl;
    else  if (r<0)
        cout<<s2<<" is larger"<<endl;
    else
        cout<<s1<<" and "<<s2<<" is eqaul"<<endl;
    
    return 0;
}