c++ - array pass by value vs an int? -


this question has answer here:

how come pass value doesnt reset array global while int pass value resets if change in function? example, items_ordered becomes 0 when return though added 1 array doesn't become how started before function called. know if pass items_ordered reference change

    #include <iostream>     using namespace std;      void meal(char menu_1[], int order);     int main()     {       char menu_order[50];       int items_ordered = 0;       meal(menu_order, items_ordered);       cout<<items_ordered<< menu_order;       return 0;     }     void meal(char menu_order[50],int items_ordered)     {     cout<< "please enter item order\n";     cin.get(menu_order, 50, '\n'); cin.ignore(100,'\n');     items_ordered += 1;     } 


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -