字符串比较代码已经放在下方

按字母顺序比较两个字符串ch1和ch2的大小,若相等,则输出0;否则输出其第一个不相等的字符的acsii编码差值。
输入描述:输入只有一组,首先在第一行上输入字符串ch1,然后在第二行输入字符串ch2,保证每个字符串长度不超过80。
输出描述:在一行上输出比较结果。若相等,则输出0;否则输出其第一个不相等的字符的acsii编码绝对差值。

样例输入:
abcdefg
abcdefh
样例输出:
1
#include
#include<bits/stdc++.h>
using namespace std;
int main(){
char a[99],b[99];
int i,t=99;
scanf("%s %s",&a,&b);
for(i=0;t!=1&&t!=-1&&t!=0;i++)
{
if(a[i]=='\0'&&b[i]=='\0')
t=0;
if(a[i]>b[i])
t=1;
if(a[i]<b[i])
t=-1;
}
printf("%d",t);

return 0;

}

img


这个代码为什么错了?
能给个正确的吗?(c++)

#include <iostream>
#include <string>

using namespace std;

int my_strcmp(const char *s1, const char *s2)
{
    while (*s1 && *s2 && *s1 == *s2)
    {
        s1++;
        s2++;
    }
    return *s1 - *s2;
}

int main()
{
    string a, b;
    cin >> a >> b;
    printf("%d", my_strcmp(a.c_str(), b.c_str()));
    return 0;
}