数组形式的首地址不可执行++和--操作

数组形式的首地址不可执行++和–操作

虽然数组名代表首地址,但是不可以像指针一样执行++--操作。
数组形式的首地址不可执行++和–操作

lvalue required as increment operand

#include <stdio.h>
#include <stdlib.h>

int main()
{
    
    
    char temp[100];
    *temp = '1';
    temp++;
    // 这段代码是错误的,数组名代表的指针是不可以执行++操作的。
    // lvalue required as increment operand
    
    //如上同
    int temp[100];
    *temp = 1;
    temp++;
}

猜你喜欢

转载自blog.csdn.net/qq_39378657/article/details/109140836
今日推荐