c语言用strcat连接两个输入的字符串

这个对么#include <string.h>#include <stdio.h>main(){char a[100] ,b[100];scanf("%s%s",a,b);printf("%d",strcat(a,b));}这样能输入两个字符么,如果不行,该怎么改才能输入两个字符串,还有怎么用strcat连接...还有这个执行不了,
是什么问题
最新回答
暴躁的喵

2024-10-22 15:29:43

#include  <string.h>
#include  <stdio.h>
int main()
{
    char a[100] ,b[100];
    scanf("%s%s",a,b);
    printf("%s",strcat(a,b));
    
}
追问
是因为%d的问题么
追答
是的,字符串输出格式为%s
藏好森林

2024-10-22 15:21:58

printf("%s",strcat(a,b)); %s不是%d 两个字符串连接后是放在a数组里面 还要保证长度不能超过a数组的长度
你继续你的骄傲

2024-10-22 17:41:01

两个%s之间至少得有空隙啊,这样的话怎么区分一个字符串结束了呢?