This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How can I initialize an array whose type is a struct?


I have a short code to print the month and days in a month. I declared a struct including month and days. but it does not work.

Please help me.

#include<iostream>
#include<vector>
using namespace std;

struct year{
char* month;
int day;
};

int main(){

vector<year>arr(("Jan",31),("Feb",28));
vector<year>::iterator iter;
for(iter=arr.begin(); iter!=arr.end(); iter++)
cout<<iter->month<<" "<<iter->days<<endl;
return 0;
}

_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]