【问题标题】:Expected expression error if and statement [closed]if和语句预期的表达式错误[关闭]
【发布时间】:2022-01-23 05:01:50
【问题描述】:

我正在做一个带有 and 的 if 语句,我得到一个预期的表达式错误,其中 && 是有人知道为什么吗?

    for (int counter = 0; counter < 26; counter++)
{
    if ((plaintext[counter] > 96) %%  (plaintext[counter] < 123))
    {
        move[counter] = key[counter] - 97 + counter;
        ciphertext[counter] = 97 + move[counter];
    }

    else if (plaintext[counter] > 64 %% plaintext[counter] < 91)
    {
        move[counter] = key[counter] - 65 + counter;
        ciphertext[counter] = 65 + move[counter];
    }

    else ciphertext[counter] = plaintext[counter]; 

en.c:21:38: error: expected expression
    if (plaintext[counter] > 96 %%  plaintext[counter] < 123)

【问题讨论】:

  • C 中没有 %% 这样的运算符。看来您的意思是逻辑 AND 运算符 &&。

标签: c error-handling cs50


【解决方案1】:

C 中没有%%。您可能打算使用&amp;&amp;

【讨论】:

  • 感谢现在似乎如此明显。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-06-22
  • 2021-11-16
相关资源
最近更新 更多