how to call?
Nov 16, 2016 at 10:49pm UTC
Hi. I made my code but now I do not know how I am to call the functions? I will attach my code. The code should call the last two functions and display the size color and price of the bags. Sorry for my poor english, it is my 2nd language.
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 70 71 72 73 74 75 76 77 78 79 80 81 82 83
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct PurseInfo
{
string color;
int size;
double price;
};
void getData(PurseInfo[]);
void printArrays(const PurseInfo[], const PurseInfo[]);
int main()
{
const int COOL_BAG = 3;
const int COOL_NUM = 2;
PurseInfo birkin[COOL_BAG] =
{
{ "Etoupe" , 35, 150.00 },
{ "Noir" , 45, 200.00 },
{ "Feu" , 30, 120.00 }
};
PurseInfo celine[COOL_NUM];
getData(celine[]);
printArrays(birkin[], celine[]);
}
void getData(PurseInfo celine[])
{
for (int i = 0; i < 2; i++)
{
cout << "Color of Purse" << i + 1 << ":\n" ;
getline(cin, celine[i].color);
cout << "Size of Purse" << i + 1 << ":\n" ;
cin >> celine[i].size;
cout << "Price of Purse" << i + 1 << ":\n" ;
cin >> celine[i].price;
cin.ignore();
}
}
void printArrays(const PurseInfo birkin[], const PurseInfo celine[])
{
cout << "Birkin: " << endl;
for (int i = 0; i < 3; i++) {
cout << "Color of Purse" << birkin[i].color << ":\n" ;
cout << "Size of Purse" << birkin[i].size << ":\n" ;
cout << "Price of Purse" << birkin[i].price << ":\n" ;
}
cout << "Celine: " << endl;
for (int i = 0; i < 2; i++) {
cout << "Color of Purse" << celine[i].color << ":\n" ;
cout << "Size of Purse" << celine[i].size << ":\n" ;
cout << "Price of Purse" << birkin[i].price << ":\n" ;
}
}
Last edited on Nov 16, 2016 at 10:51pm UTC
Nov 17, 2016 at 12:50am UTC
just pass the name of the array:
1 2
getData(celine);
printArrays(birkin, celine);
Topic archived. No new replies allowed.