I'm relatively new to C++/coding and I'm working on my final project for CS2. I'm trying to design a "recipe calculator" that will take in 3 ingredients(into a vector) then search through a recipe database for potential recipes.
Currently, I'm struggling with some basics, when I call the function that initializes the vector, it won't output the ingredients again in the main. When I try to output the vector inside the actual function, it works. But I want to make sure the same vector is saved in "ingreds" in the main.
int main()
{
    int y;
    cout << "Hello! Welcome to Abby's Recipe Calculator." << endl << endl;
    cout << "Please select an option: 1 to search by ingredient or 2 to browse recipes..." << endl;
    cin >> y;
    vector <string> ingreds;
    ingreds.reserve(4); 
    if (y == 1)
    {
        ingredientvector(ingreds);
        for (int i = 0; i < ingreds.size(); i++)
        {
            std::cout << ingreds[i];
        }
    }
    //else if (y == 2)
    //{
    //call recipe function... 
    //}
    system("pause");
    return 0;
}
vector<string> ingredientvector(vector<string> x)
{
    cout << "SEARCH BY INGREDIENT" << endl;
    cout << "Please enter up to three ingredients... " << endl;
    for (int i = 0; i < 4; i++)
    {
        x.push_back("  ");
        getline(cin, x[i]);
        if (x[i] == "1")
        {
            break;
        }
    }
    return x;
}
 
     
     
    