#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main() {
char str1[100];
char str2[100];
char result[200];
printf("请输入第一个字符串: ");
fgets(str1, sizeof(str1), stdin);
// 去除fgets读取的换行符
str1[strcspn(str1, "\n")] = '\0';
printf("请输入第二个字符串: ");
fgets(str2, sizeof(str2), stdin);
str2[strcspn(str2, "\n")] = '\0';
strcpy(result, str1);
strcat(result, str2);
int j = 0;
for (int i = 0; result[i] != '\0'; i++) {
if (!isspace(result[i])) {
result[j++] = result[i];
}
}
result[j] = '\0';
printf("拼接并去除空格后的字符串: %s\n", result);
return 0;
}