#if 1
//問題⑫
#include <stdio.h>
#include <string.h>
void cString(char *str1, char *str2);
int main(void)
{
char str1[] = "asaa";
char str2[] = "aaaa";
cString(str1, str2);
}
void cString(char *str1 ,char *str2){
int n_1 = 0;
int n_2 = 0;
char* def_1 = &str1[0];
char* def_2 = &str2[0];
while (*str1 != '\0'){
*str1++;
n_1++;
}
while (*str2 != '\0'){
*str2++;
n_2++;
}
if (n_1 == n_2){
str1 = def_1;
str2 = def_2;
int agreement = 0;
for (int i = 0; i < n_1; i++){
if (*str1 == *str2){
agreement++;
}
*str1++;
}
if (agreement == n_1){
printf("一致しました");
}
else{
printf("一致しませんでした");
}
}
else if (n_1 < n_2){
printf("引数1『");
str1 = def_1;
for (int i = 0; i < n_1; i++){
printf("%c", *str1);
*str1++;
}
printf("』の数が少ない\n");
}
else if (n_1 > n_2){
printf("引数2『");
str2 = def_2;
for (int i = 0; i < n_2; i++){
printf("%c", *str2);
*str2++;
}
printf("』の数が少ない\n");
}
}
#endif
どこを改善したらいいでしょうか?
どなたか教えてください。