首页 > 解决方案 > 我如何将 ' 视为普通字母

问题描述

else if (isspace(text[i]) || (text[i]) == ')
{
    words++;
}

在终端中显示:“错误:缺少终止字符 [-Werror,-Winvalid-pp-token]”。

标签: ccompiler-errorssyntax-errorcharacter

解决方案


单个字符由'围绕它们的单引号 ( ) 表示,甚至是'字符本身 - 尽管您需要使用反斜杠 ( \) 对其进行转义:

else if (isspace(text[i]) || (text[i]) == '\'')
{
    words++;
}

推荐阅读