相同的代碼在TURBO C.使用GCC結構和得到錯誤
struct details
{
char name[20];
int year;
float price;
}my_str;
details book1[10];
此錯誤產生跑去。這怎麼解決?
ram.c: In function ‘main’:
ram.c:11:1: error: ‘details’ undeclared (first use in this function)
ram.c:11:1: note: each undeclared identifier is reported only once for each function it appears in
的原因喲你得到的錯誤是,在C++中它允許像上面那樣寫,但在C中不是。我的猜測是,Borland將它作爲Turbo C的延伸,因爲它們正朝着C++方向發展。 –