Using Array as function pararmeter

I am using this function to obtain data from either .txt or .dat and part of them are going to a string file. However, I cannot compile this function and is giving me a warning about string itemname parameter and unit parameter.

void getdata(char sortletter[maxitem],int number[maxitem], string itemname[maxitem],string unit[maxitem],double price[maxitem]);

can i use string as a function parameter? If not how can I input the string from an infile command?

currently my function definition looks like this


void getdata(char sortletter[maxitem],int number[maxitem], string itemname[maxitem],string unit[maxitem],double price[maxitem])
{ using namespace std;
int i =0;
ifstream infile1("H:\\CSC\\lab8\\NJTemp.dat");
do {
infile1 >> sortletter[i];
infile1 >> number[i];
infile1 >> itemname [i];
infile1 >> unit [i];
infile1 >> price [i];
i++;

} while (i<400);


}


and data file should look something like this

M 1 AAA lb 1.99
M 2 AAB lb 2.99
M 3 ABB case 2.99
V 1 AAA lb 3.99
Topic archived. No new replies allowed.