一个C++程序??能在VC++6.0上编译,但不能运行,但是在Dev-C++是能运行??是什么原因??
#include<iostream>usingnamespacestd;structStudent{intnum;charname[20];floatscore[3];}...
#include <iostream>
using namespace std;
struct Student
{int num;
char name[20];
float score[3];
}student[5];
int main()
{int i;
for(i=0;i<5;i++)
cin>>student[i].num>>student[i].name>>student[i].score[0]>>student[i].score[1]>>student[i].score[2];
void print(Student student[]);
print(student);
return 0;
}
void print(Student *p)
{int i;
for(i=0;i<5;i++)
cout<<student[i].num<<" "<<student[i].name<<" "<<student[i].score[0]<<" "<<student[i].score[1]<<" "<<student[i].score[2];
} 展开
using namespace std;
struct Student
{int num;
char name[20];
float score[3];
}student[5];
int main()
{int i;
for(i=0;i<5;i++)
cin>>student[i].num>>student[i].name>>student[i].score[0]>>student[i].score[1]>>student[i].score[2];
void print(Student student[]);
print(student);
return 0;
}
void print(Student *p)
{int i;
for(i=0;i<5;i++)
cout<<student[i].num<<" "<<student[i].name<<" "<<student[i].score[0]<<" "<<student[i].score[1]<<" "<<student[i].score[2];
} 展开
2个回答
展开全部
你这是最新的C++标准
在VC++6.0当中没有namespace的概念
#include <iostream>也应该是#include <iostream.h>
即:
#include <iostream.h>
//using namespace std;
struct Student
{int num;
char name[20];
float score[3];
}student[5];
int main()
{int i;
for(i=0;i<5;i++)
cin>>student[i].num>>student[i].name>>student[i].score[0]>>student[i].score[1]>>student[i].score[2];
void print(Student student[]);
print(student);
return 0;
}
void print(Student *p)
{int i;
for(i=0;i<5;i++)
cout<<student[i].num<<" "<<student[i].name<<" "<<student[i].score[0]<<" "<<student[i].score[1]<<" "<<student[i].score[2];
}
在VC++6.0当中没有namespace的概念
#include <iostream>也应该是#include <iostream.h>
即:
#include <iostream.h>
//using namespace std;
struct Student
{int num;
char name[20];
float score[3];
}student[5];
int main()
{int i;
for(i=0;i<5;i++)
cin>>student[i].num>>student[i].name>>student[i].score[0]>>student[i].score[1]>>student[i].score[2];
void print(Student student[]);
print(student);
return 0;
}
void print(Student *p)
{int i;
for(i=0;i<5;i++)
cout<<student[i].num<<" "<<student[i].name<<" "<<student[i].score[0]<<" "<<student[i].score[1]<<" "<<student[i].score[2];
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询