Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

difficulty declaring a vector<structs>

Status
Not open for further replies.

ShawnCoutts

Programmer
Jul 4, 2006
74
CA
I am trying to declare a vector of structs.
i have a header file that has definitions of all my structs and a typedef associated with them.

for some reason this does not work:

Code:
vector<HEADER> h;

where HEADER is equal to:

 typedef struct header{
        char record_type[2];
        char sender[5];
        char recipient[5];
        char file_seq_num[5];
        char tax_treatment[1];
        char tax_rate[5][3];                //each location holds another array of 3 bytes
        char file_create_date[6];
        char file_trans_date[6];
        char trans_cutoff_time[12];
        char utc_time_offset[5];
        char spec_ver_num[2];
        char international_access_code[12];
        char country_code[8];
} HEADER;

can someone explain to me why i keep getting a declaration error?
 
typedef struct header{" could be the fault.
Try "typedef struct {"

Or is it the 'vector' that gives error? Wondering cause i've never seen that declaration before in C(++).

It should, according to mu knowledge, look like this:
HEADER * h; // Declaring a pointer to a HEADER-structure

Totte
Keep making it perfect and it will end up broken.
 
just to let you know, I managed to solve the problem.
It wanted a namespace. So once I added namespace std everything worked fine.

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top