我写了两个程序。。是一模一样的。。但是有一个编译的时候能通过。。另一个不能。
这个是能通过编译的:
#include <iostream>
struct car 
{ 
    char name[20]; 
    int year;
    };
int main(void)
{ 
   using namespace std;
    int n;
    cout << "How many cars do you wish to catalog?: ";
    cin >> n;
  
    car * pc = new car [n];
    int i;
    for (i = 0; i < n; i++)
    {
        cout << "Car #" << (i + 1) << ":\n";
        cout << "Please enter the make: ";
        cin.getline(pc[i].name,20);
        cout << "Please enter the year made: ";
        cin >> pc[i].year;
        
    }
    cout << "Here is your collection:\n";
    for (i = 0; i < n; i++)
        cout << pc[i].year << " " << pc[i].name << "\n";
    delete [] pc;
    return 0;
}
这个是不能通过编译的:
#include<iostream>
struct car
{    
     char name[20];
     int year;
    };
int main(void)
{
    using namespace std;
    int n;
   cout << "How many cars do you wish to catalog?: ";
   cin >> n    ;
     car* pc = new car[n];
     int i;
     for (i = 0; i < n; i++)
    {
        cout << "Car #" << (i + 1) << ":\n";
        cout << "Please enter the make: ";
        cin.getline(pc[i].name,20);
        cout << "Please enter the year made: ";
        cin >> pc[i].year;
       
    }
      cout << "Here is your collection:\n"
      for (i=0 ; i<n ; i++)
          cout << pc[i].year << " " << pc[i].name << "\n";
          delete [] pc;
      return 0 ;
    }
这个没能通过编译的程序,显示:
Error E2379 10.cpp 25: Statement missing ; in function main()
Error E2379 10.cpp 25: Statement missing ; in function main()



 
											





 
	    

 
	



 倒数第五行少了个;号
倒数第五行少了个;号										
					
	 
										
					
	