need help with structs

I'm learning structs and I'm having trouble understanding it. I'm trying to pass in my struct to my read function and I'm getting an error "parameter 1 of 'void read(WIR)' has incomplete type 'WIR'" and I'm pretty sure I'm reading in my data incorrectly but I'm not sure

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
#include <fstream>
#include <iomanip>
//Jacob Wilt
//Warehouse Inventory Report
using namespace std;
ifstream infile1, infile2, infile3, infile4;
ofstream outfile;
int cnt = 0;
const int Max = 65;
int Item_Number;
string WareHouse_Name;
string Item_Name;
int Quantity;
double WSP;
double MarkUp;
double Retail;
struct WIR;
void openfiles();
void read(WIR);
void closefiles();
int main()
{
    openfiles();
    struct WIR
    {
        int Item_Number;
        string WareHouse_Name;
        string Item_Name;
        int Quantity;
        double WSP;
        double MarkUp;
        double Retail;
    };
    WIR WH[Max];
    read(WH);
    return 0;
}
void openfiles()
{
    infile1.open("C:\\Users\\Jacob\\Desktop\\WLL1.txt");
    infile2.open("C:\\Users\\Jacob\\Desktop\\WLL2.txt");
    infile3.open("C:\\Users\\Jacob\\Desktop\\WLL3.txt");
    infile4.open("C:\\Users\\Jacob\\Desktop\\WLL4.txt");
    outfile.open("WarehouseOutfile.txt");
}
void read(WIR WH[])
{
    int i;
    for(i = 0; i < Max; i++)
    {
        infile2 >> WH[i].Item_Number >> WH[i].WareHouse_Name;
        infile1 >> WH[i].Item_Number >> WH[i].Item_Name;
        infile3 >> WH[i].Item_Name >> WH[i].Quantity;
        infile4 >> WH[i].Item_Name >> WH[i].Item;
    }
}
void print()
{

}
void closefiles()
{
    infile1.close();
    infile2.close();
    infile3.close();
    infile4.close();
    outfile.close();
}
Function can see only type names which have been defined before it. SO declaration of your read() function searches for WIR type on lines 1-20. And it didn't finds it. Move your struct definition before read() declaration (why did you place it in main()?)
Topic archived. No new replies allowed.