检查字符是否为单引号.c++
check if a char is a single quote. c++
我想检查一个字符是否是单引号。这是我的密码。
char mychar;
if (mychar == ''') // Is that how we check this char is a single quote?
{
cout << "here is a quote" << endl;
}
您的代码片段无效。代替
char mychar;
if(char==''')// is that how we check this char is a single quote?
{
cout<<"here is a quote"<<endl;
}
必须有
char mychar;
if(mychar==''')// is that how we check this char is a single quote?
{
cout<<"here is a quote"<<endl;
}
而且对象CCD_ 1必须被初始化。
至于其他那个么你们必须使用包含单引号转义符的文字。
或者如果你有一个字符串文字像
const char*quote="'";
然后你可以写为
if( mychar == *quote )
或
if( mychar == quote[0] )
是。(假设您修复了char
而不是mychar
的拼写错误。)
相关文章:
- 单引号在C++数学编程中是什么意思?
- wcout不会打印正确的单引号
- C++ 中数组(单引号和双引号)的可视常量字符* 与字符
- 使用带有 std::cout 的单引号打印字符串实际上打印了数字
- 匹配外部单引号之间的字符串
- 如何使用C++中不是文字的变量在数字中显示单引号和两个引号?假设 6'2" 英尺
- 正则表达式使用提升令牌迭代器在单引号和括号之间提取值
- 如何在QT中正确逃脱单引号和双引号
- 为什么'char'值必须有单引号而不是双引号?
- C++单引号语法
- 修改正则表达式以包含反斜杠和单引号(以便反斜杠表现为转义字符)
- iSpunct()未检测到单引号字符
- 以C++显示时带有单引号和双引号的不同答案
- 使用 getline() 在单引号中读取
- 在 C# 中将单引号字符串到 uint
- C/C++ 中的单引号、双引号和大小 ('a')
- PQexecParams 使用单引号失败
- 单引号(撇号)要打印到屏幕C++的字母
- C++中的转义序列用单引号括起来,而不是用双引号括起来
- 从字符串c++中删除单引号字符