|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
求助求助!为什么这个代码编译不了,代码从小甲鱼那复制来的。
#include <stdio.h>
#include <string.h>
int main()
{
char str1[] = "love";
char str2[] = "FishC";
if (strlen(str1) - strlen(str2) < 0)
{
printf("字符串"%s"比字符串"%s"短!\n", str1, str2);
} //删除上面%s两边双引号就是正常编译
else
{
printf("字符串"%s"比字符串"%s"长!\n", str1, str2);
}
return 0;
}
本帖最后由 major_lyu 于 2020-2-25 00:18 编辑
printf()函数里面只允许出现一对双引号表示格式化输出,如果你想在输出的字符中包含双引号,所要显示的双引号要用\进行转义
- #include <stdio.h>
- #include <string.h>
- int main()
- {
- char str1[] = "love";
- char str2[] = "FishC";
- if (strlen(str1) - strlen(str2) < 0)
- {
- printf("字符串\" % s \"比字符串\" % s \"短!\n", str1, str2);
- } //删除上面%s两边双引号就是正常编译
- else
- {
- printf("字符串\" % s \"比字符串\" % s \"长!\n", str1, str2);
- }
- return 0;
- }
复制代码
|
|