| | |
Problems with function parameter...
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 23
Reputation:
Solved Threads: 0
I'm juz wondering how do I send a single value to a 8-parameter function...
how do i send to the correct variable...since the displaydata has more than one parameter
C++ Syntax (Toggle Plain Text)
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
Last edited by gopi17; Aug 7th, 2009 at 5:53 am.
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.
![]() |
Similar Threads
- Having Function Problems... (C++)
- Trying to put the value of a variable into a function parameter (JavaScript / DHTML / AJAX)
- Recursive function with parameter - array of chars. (C++)
- template object as function parameter (C++)
- Problem Using a Function Parameter in a MySQL Statement (Python)
- function with an open stream as a parameter (C++)
- passing function as a parameter to another function (C++)
- Deleting characters function ( with just one parameter) (C)
Other Threads in the C++ Forum
- Previous Thread: how does C++ know which constructor to call if you don't specify one?
- Next Thread: Good books for learning c++
| Thread Tools | Search this Thread |
api array arrays based binary c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





