このコードを試しましたが、動作していないように見えます。2つの配列が完全に異なる場合は1を返し、共通の要素がある場合は0を返します。
#include <stdio.h>
#include <string.h>
int meme(char s1[], char s2[])
{
int i = 0, j = 0;
int different;
while (i <= strlen(s1) && different == 1) {
while (j <= strlen(s2)) {
if (s1[i] != s2[j]) {
different = 1;
} else {
different = 0;
}
j = j + 1;
}
i = i + 1;
}
return different;
}
デバッガでコードをステップ実行しようとしましたか? – pm100
開始すると異なる初期化されませんでした - したがってyrループはおそらく実行されません – pm100
'different'は未定義です。ところで、あなたのユースケースのために 'for'ループを使う方が良いでしょう。 – RoiHatam