Vc 结构体问题

来源:百度知道 编辑:UC知道 时间:2024/06/03 07:05:01
#include "stdafx.h"
#include <iostream>
using namespace std ;
struct weather
{
double temp ;
double wind ;
};
void main()
{struct weather today[10];
today[0].temp=35;
today[0].wind=7;
cout<<today.temp<<endl;
cout<<today.wind<<endl;
}
Error 1 error C2228: left of '.temp' must have class/struct/union h:\workspace\struct 1\struct 1\struct 1.cpp 13 struct 1
Error 2 error C2228: left of '.wind' must have class/struct/union h:\workspace\struct 1\struct 1\struct 1.cpp 14 struct 1
我用结构体定义数组,就会出现这个问题,郁闷死了。但是不适用数组就编译通过,那里的问题希望大家帮帮忙,对了
我想打开 Vc中可以查看代码所在的行的的东东, 不知道怎么打开大家帮帮忙

#include "stdafx.h"

#include <iostream>
using namespace std ;
struct weather
{
double temp ;
double wind ;
};
void main()
{ weather today[10]; ///////////////////不需要struct
today[0].temp=35;
today[0].wind=7
cout<<today[0].temp<<endl;////////////////////////////的引用错
cout<<today[0].wind<<endl;;////////////////////////////你的引用错了
}

快给分

不知道你用的是哪一个版本的编译器呢?
vs2008的话在 视图->其他窗口->错误列表,然后在屏幕下方就可以找到错误列表的选项卡了

还有就是你输出的时候忘了加数组的标号了...
cout<<today[0].temp<<endl;
cout<<today[0].wind<<endl;