| | |
sub proceedure/function Qs
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 63
Reputation:
Solved Threads: 0
this is my sub proceedure
will this work? will i need to declare the array before i call the sub proceedure and can i return both those pieces of info?
the array needs to be a float because the numbers wont be integers when i go to run the program properly.
"pat" is declared before it enters the function, and its number dictates which array values are used in the main program. not sure whether it is needed to be returned unless pat being incrimented isnt recognised in main program, also pretty sure now that pat shouldnt be in that return bracket
im not sure if this is correct
the values of the array is the important thing
C++ Syntax (Toggle Plain Text)
/****************************************************************************** * * Name: patpixselect * Parameters: none * Returns: patpix[] * Globals: none * Description: database for which pixels for which pattern *****************************************************************************/ int patpixselect (int pat); { float patpix[9] ; // array for pixels in patterns if (pat == 1) { patpix[0] = 1; patpix[1] = 1; patpix[2] = 1; patpix[3] = 1; patpix[4] = 1; patpix[5] = 1; patpix[6] = 1; patpix[7] = 1; patpix[8] = 1; ++pat; return (patpix[9], pat) } if (pat == 2) { patpix[0] = 2; patpix[1] = 2; patpix[2] = 2; patpix[3] = 2; patpix[4] = 2; patpix[5] = 2; patpix[6] = 2; patpix[7] = 2; patpix[8] = 2; ++pat; return (patpix[9], pat) } if (pat == 3) { patpix[0] = 3; patpix[1] = 3; patpix[2] = 3; patpix[3] = 3; patpix[4] = 3; patpix[5] = 3; patpix[6] = 3; patpix[7] = 3; patpix[8] = 3; pat = 1; return (patpix[9], pat) } }
will this work? will i need to declare the array before i call the sub proceedure and can i return both those pieces of info?
the array needs to be a float because the numbers wont be integers when i go to run the program properly.
"pat" is declared before it enters the function, and its number dictates which array values are used in the main program. not sure whether it is needed to be returned unless pat being incrimented isnt recognised in main program, also pretty sure now that pat shouldnt be in that return bracket
im not sure if this is correct
the values of the array is the important thing
•
•
Join Date: Jan 2008
Posts: 3,818
Reputation:
Solved Threads: 501
•
•
•
•
this is my sub proceedure
C++ Syntax (Toggle Plain Text)
/****************************************************************************** * * Name: patpixselect * Parameters: none * Returns: patpix[] * Globals: none * Description: database for which pixels for which pattern *****************************************************************************/ int patpixselect (int pat); { float patpix[9] ; // array for pixels in patterns if (pat == 1) { patpix[0] = 1; patpix[1] = 1; patpix[2] = 1; patpix[3] = 1; patpix[4] = 1; patpix[5] = 1; patpix[6] = 1; patpix[7] = 1; patpix[8] = 1; ++pat; return (patpix[9], pat) } if (pat == 2) { patpix[0] = 2; patpix[1] = 2; patpix[2] = 2; patpix[3] = 2; patpix[4] = 2; patpix[5] = 2; patpix[6] = 2; patpix[7] = 2; patpix[8] = 2; ++pat; return (patpix[9], pat) } if (pat == 3) { patpix[0] = 3; patpix[1] = 3; patpix[2] = 3; patpix[3] = 3; patpix[4] = 3; patpix[5] = 3; patpix[6] = 3; patpix[7] = 3; patpix[8] = 3; pat = 1; return (patpix[9], pat) } }
will this work? will i need to declare the array before i call the sub proceedure and can i return both those pieces of info?
the array needs to be a float because the numbers wont be integers when i go to run the program properly.
"pat" is declared before it enters the function, and its number dictates which array values are used in the main program. not sure whether it is needed to be returned unless pat being incrimented isnt recognised in main program, also pretty sure now that pat shouldnt be in that return bracket
im not sure if this is correct
the values of the array is the important thing
You have some semicolon problems and you have a potential segmentation fault. Why are you using the comma operator? If you are trying to return an array:
•
•
•
•
* Returns: patpix[]
int* patpixselect (int pat);See this thread:
http://www.daniweb.com/forums/thread5939.html
![]() |
Similar Threads
- sub proceedure variables. (C++)
- A multilingual coded Hello World! thread (Legacy and Other Languages)
- Writing a javascript function (JavaScript / DHTML / AJAX)
- Proper process termination (Assembly)
- Linux API - how to use it (C)
Other Threads in the C++ Forum
- Previous Thread: problems with compiler
- Next Thread: vector trouble
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






