I was wondering why do I keep getting an error and unable to return an array;
also, once the sell_item function actually work and return an array..how do I echo that array from the main function.
thanks
#include <iostream>
#include <fstream>
using namespace std;
ifstream infile;
ofstream outfile;
int itemnum = 3333;
string itemName="Cooking Range";
int Qauntity=1;
int NumberOfItems=2;
int NumberOfFields=5;
double function_Sell_Item(int itemnum,string itemName, int Qauntity);
int main () {
function_Sell_Item(itemnum, itemName, Qauntity);
}
double function_Sell_Item(int itemnum,string itemName, int Qauntity) {
double arraylist[2][5];
for (int index =0; index < NumberOfItems; index++) {
for (int i=0; i < NumberOfFields; i++) {
arraylist[index][i]=0;
}
}
return arraylist;
}
//// functions ends
:
;
You’re trying to return an array, which you cannot do in C++.
You should consider something like
std::vector<double>, because you can return that.