|
郁闷的,看的一午的书,再上练习,怎么调试都调不好,不知道哪里出了问题,高手帮忙指点!!!
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
struct Student
{
int num;
char name[10];
char sex;
int age;
float score[3];
}stu[2];
int main()
{
int k;
Student stu;
stu={101,"zhang",'M',19,95.5,64.0};
cout<<stu.num;
return 0;
}
错误提示:
Compiling...
number three.cpp
D:\c++\number three.cpp(17) : error C2059: syntax error : '{'
D:\c++\number three.cpp(17) : error C2143: syntax error : missing ';' before '{'
D:\c++\number three.cpp(17) : error C2143: syntax error : missing ';' before '}'
执行 cl.exe 时出错.
如果将Student stu;
stu={101,"zhang",'M',19,95.5,64.0};
改成Student stu={101,"zhang",'M',19,95.5,64.0};程序就不出错的,不知道这两者有什么区别。 |
|