【问题标题】:Lvalue Required As Increment Operand | C error [closed]需要作为增量操作数的左值 | C错误[关闭]
【发布时间】:2022-01-02 11:41:49
【问题描述】:

我正在制作一个简单的操作系统。我制作了一个 screen.h 文件以允许我打印字符串、清除行等。但是当我使用 gcc 编译它时,它说

src/include/screen.h: In function ‘scrollUp’:
src/include/screen.h:46:29: error: lvalue required as increment operand
   46 |     for(i; i<sw*(sh-1)*sd; 1++)
      |

有人可以帮帮我吗?

这是代码

void scrollUp(uint8 lineNumber) 
{
    string vidmem = (string)0xb8000;
    uint16 i = 0;
    for(i; i<sw*(sh-1)*sd; 1++)
    {
        vidmem[i] = vidmem[i + sw * sd * lineNumber];    
    }
    clearLine(sh - 1 - lineNumber, sh - 1);
    if((cursorY-lineNumber) < 0)
    {
        cursorX = 0;
        cursorY = 0;
    }
    else
    {
        cursorY -= lineNumber;
    }
    updateCursor();
}

谢谢!

【问题讨论】:

  • 1++ --> i++

标签: c error-handling increment lvalue operands


【解决方案1】:
1++

是你要找的错误,我相信你的意思是

i++

如果您有意编写 1++,则不能这样做,因为 ++ 运算符的作用是

  • 读取值
  • 加一个
  • 节省价值

在没有变量存储的情况下如何保存价值?

【讨论】:

    猜你喜欢
    • 2011-09-07
    • 2020-10-06
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-10
    • 2012-10-01
    • 1970-01-01
    相关资源
    最近更新 更多