gpt4 book ai didi

c++ - "Illegal case"在 c++ 中使用特殊符号以防万一

转载 作者:太空宇宙 更新时间:2023-11-04 06:03:02 25 4
gpt4 key购买 nike

当我在 C++ 中使用特殊字符大小写时,我遇到了一些问题。我尝试使用“{”,但错误结束。 Visual Studio 2010。这是我的代码。

for (int i = 0; i < inputString.length(); i++)
{
switch(inputString[i])
case '{':
nowChar = inputString[i];
nowCaret = i;
break;
case '[':
nowChar = inputString[i];
nowCaret = i;
break;
case '(':
nowChar = inputString[i];
nowCaret = i;
break;
}

如何消除这些错误?我真的不知道。

最佳答案

你需要用大括号打开和结束你的开关。

switch() {
// ...
}

关于c++ - "Illegal case"在 c++ 中使用特殊符号以防万一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15802699/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com