[Warning] unknown escape sequence: '\040' 是什么?
#include <stdio.h>int main()
{
char isRain, isFree;
printf("是否有空?(Y \ N)");//这里出现了:7 13 C:\Users\Administrator\Desktop\take\c\0053.cpp unknown escape sequence: '\040'
scanf("%c", &isFree);
getchar ();
printf("是否下雨?(Y \ N)");//在这里和上面的括号两个地方出现的这个警告
scanf("%c", &isRain);
if ('Y' == isFree)
{
if ('Y' == isRain)
{
printf("记得带雨伞哦\n");
}
else
{
printf("记得一起看电影哦\n");
}
}
else if ('N' == isFree)
{
printf("女神没空,真可惜\n");
}
else if ('N' != isFree , 'Y' != isFree)
{
printf("请输入大写Y与N\n");
}
return 0;
}
#include <stdio.h>
int main()
{
char isRain, isFree;
printf("是否有空?(Y \ N)");//这里出现了:7 13 C:\Users\Administrator\Desktop\take\c\0053.cpp unknown escape sequence: '\040'
scanf("%c", &isFree);
getchar ();
printf("是否下雨?(Y \ N)");//在这里和上面的括号两个地方出现的这个警告
scanf("%c", &isRain);
if ('Y' == isFree)
{
if ('Y' == isRain)
{
printf("记得带雨伞哦\n");
}
else
{
printf("记得一起看电影哦\n");
}
}
else if ('N' == isFree)
{
printf("女神没空,真可惜\n");
}
else if ('N' != isFree , 'Y' != isFree)
{
printf("请输入大写Y与N\n");
}
return 0;
}
{
char isRain, isFree;
printf("是否有空?(Y \ N)");//这里出现了:7 13 C:\Users\Administrator\Desktop\take\c\0053.cpp unknown escape sequence: '\040'
scanf("%c", &isFree);
getchar ();
printf("是否下雨?(Y \ N)");//在这里和上面的括号两个地方出现的这个警告
scanf("%c", &isRain);
if ('Y' == isFree)
{
if ('Y' == isRain)
{
printf("记得带雨伞哦\n");
}
else
{
printf("记得一起看电影哦\n");
}
}
else if ('N' == isFree)
{
printf("女神没空,真可惜\n");
}
else if ('N' != isFree , 'Y' != isFree)
{
printf("请输入大写Y与N\n");
}
return 0;
} printf("是否有空");
把字符串中的特殊字符去掉吧。尽喜欢搞特殊 这么改:
#include <stdio.h>
int main()
{
char isRain, isFree;
printf("是否有空?(Y / N)");//这里出现了:7 13 C:\Users\Administrator\Desktop\take\c\0053.cpp unknown escape sequence: '\040'
scanf("%c", &isFree);
getchar ();
printf("是否下雨?(Y / N)");//在这里和上面的括号两个地方出现的这个警告
scanf("%c", &isRain);
if ('Y' == isFree)
{
if ('Y' == isRain)
{
printf("记得带雨伞哦\n");
}
else
{
printf("记得一起看电影哦\n");
}
}
else if ('N' == isFree)
{
printf("女神没空,真可惜\n");
}
else if ('N' != isFree , 'Y' != isFree)
{
printf("请输入大写Y与N\n");
}
return 0;
} 字符串中出现了反斜杠 \ 。由于反斜杠是转义字符,所以要打印一个反斜杠应该用两个反斜杠表示。
#include <stdio.h>
int main()
{
char isRain, isFree;
printf("是否有空?(Y \\ N)"); //这里出现了:7 13 C:\Users\Administrator\Desktop\take\c\0053.cpp unknown escape sequence: '\040'
scanf("%c", &isFree);
getchar();
printf("是否下雨?(Y \\ N)"); //在这里和上面的括号两个地方出现的这个警告
scanf("%c", &isRain);
if ('Y' == isFree)
{
if ('Y' == isRain)
{
printf("记得带雨伞哦\n");
}
else
{
printf("记得一起看电影哦\n");
}
}
else if ('N' == isFree)
{
printf("女神没空,真可惜\n");
}
else if ('N' != isFree, 'Y' != isFree)
{
printf("请输入大写Y与N\n");
}
return 0;
}
页:
[1]