Ask your own question, for FREE!
Computer Science 11 Online
OpenStudy (anonymous):

What if I want to call a function that scans for two integers then processes then the results will be then passed on another function then it will process it then the same thing happens again for the second time (I think) What would it look like? Please be more specific in the ampersand and pointer part like void printSomething(int *a,int *b)

OpenStudy (rsmith6559):

Syntax wise, you've got it for C. For C++, you may need to make them a reference to the pointer. Since you'd be working on a common set of numbers, it's no bad to do the calls. Since you're working ON the numbers, you have no return problems. The main thing is that that logic is a bit convoluted.

OpenStudy (anonymous):

how will it look like can you type an example for me??? I would appreciate it by giving some medals. xD

OpenStudy (rsmith6559):

If you're calling a function that operates on a pointer/reference (I still don't know if we're talking C or C++), any changes to the value ( *a ) will change the value of the calling function's variable. So you can return void from the called function. The reason for passing pointers/references in C/C++ is that the called function gets a copy of the passed variables. If pointers/references are passed, the copy still points to the value, so any value changes in the function persist after the function returns. If the function is passed a copy of the value, and it's changed, it's destroyed when the function returns and it's stack frame is cleaned up.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: i need help
1 day ago 7 Replies 1 Medal
Arriyanalol: CONGRATS to me
1 day ago 8 Replies 2 Medals
Legomaster346: What colleges are good that are near Arab Alabama?
1 week ago 5 Replies 0 Medals
Arriyanalol: i need help
1 week ago 6 Replies 2 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!