0

I'm juz wondering how do I send a single value to a 8-parameter function...

void enterdata1(int &row1col2)
{
    cout<<"Please enter the number for Row 1-Columm 2"<<endl;
    cin>>row1col2;
    if(row1col2 != 1 && row1col2 != 2&& row1col2 != 3 && row1col2 != 4)
    {
                cout<<"Please enter the correct number (Which is between 1-4)"<<endl;
                cin>>row1col2;
    }
     displaydata(row1col2);
}

void displaydata( int &row1col1,int &row1col2,int &row1col3,int &row1col4,int &row2col1,
                  int &row2col2,int &row2col3,int &row2col4,int &row3col1,int &row3col2,
                  int &row3col3,int &row3col4,int &row4col1,int &row4col2,int &row4col3,
                  int &row4col4)
{
    cout<<" |-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|"<<endl;
    cout<<" | "<<row1col1<<" | "<<row1col2<<" | "<<row1col3<<" | "<<row1col4<<" |"<<endl;
    cout<<" |-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|"<<endl;
    cout<<" | "<<row2col1<<" | "<<row2col2<<" | "<<row2col3<<" | "<<row2col4<<" |"<<endl;
    cout<<" |-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|"<<endl;
    cout<<" | "<<row3col1<<" | "<<row3col2<<" | "<<row3col3<<" | "<<row3col4<<" |"<<endl;
    cout<<" |-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|"<<endl;
    cout<<" | "<<row4col1<<" | "<<row4col2<<" | "<<row4col3<<" | "<<row4col4<<" |"<<endl;
    cout<<" |-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|-"<<"-"<<"-|"<<endl;
    
    system("pause");
}

how do i send to the correct variable...since the displaydata has more than one parameter

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by necrolin
0

If you only pass one parameter to the function then what's the program supposed to do with the other 8?? Besides, regardless of the name of the variable that you're sending the data will go to the first parameter in the function. So basically you're sending row1col2 to row1col1... which is not what you want to do. Why can't you pass all 8 parameters at the same time? You can have the function enterdata1() just return the value to main and have main call the displaydata() function with all 8 parameters.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.