我正在编写一个程序来比较两个字符串而不使用strcmp().但是,我无法得到我想要的结果.这是我的程序的代码.
#include<stdio.h>
int main(int argc, char const *argv[]) {
int i,j;
char a[90],b[90];
printf("Enter the first string:");
scanf("%s", &a[90]);
printf("Enter the second string:");
scanf("%s", &b[90]);
for ( i = 0; a[i] != '\0' && b[i] != '\0'; i++) {
if (a[i] == b[i]) {
/* code */
printf("Equal %d \n", a[i]-b[i]);
continue;
} if (a[i] > b[i]) {
/* code */
printf("ai is big %d \n", a[i]-b[i]);
break;
}
if (a[i] < b[i]) {
/* code */
printf("%d bi is …Run Code Online (Sandbox Code Playgroud)