為什么會顯示兩個錯誤
#include <stdio.h>
struct weapon{
?char name[20];
?int atk;
?int price;
};
int main(){
?int a=10;
?float b=20;
?struct weapon weapon_1{"weapon_name",100,200};//初始化結構體
?printf("%s\n,%d\n",weapon_1.name,++weapon_1.price);//訪問結構體對象中的某一個成員中的值,結構體中的變量也可以進行運算
?return 0;
}
D:\Visual?C筆記\結構體初始化和引用.cpp(10)?:?error?C2601:?'weapon_1'?:?local?function?definitions?are?illegal D:\Visual?C筆記\結構體初始化和引用.cpp(10)?:?error?C2063:?'weapon_1'?:?not?a?function
倒數第四行顯示有兩個錯誤,這是為什么呢?望指點
2019-10-20
看了半天,才發現在倒數第四行代碼少了個“=”號?