# return decimal number back caller function

• 10-10-2009
andy09
return decimal number back caller function
Hi,

I am new to pointer..and trying to use pointer in my program.

here is what I want pointer does....

IN my program, I have a function definition that return back to caller function with a decimal number. now, i want save that value, and everytime i return another decimal number, i want to save that decimal again...kept doing it until i return all decimal back to caller function...now, i want to retreat and perform the Or operation......

Can someone look at my code, and suggest how to code in pointer? can pointer is a way to save all your values everytime you return decimal number back caller function?

please refer to file 4 code pointer

can someone look at my above code...i think i have wrong, but not sure how to use pointer in my code.... i want to save all my decimal number when return decimal number back caller function... please help?

the only way i think pointer will do my trick? I am not sure ?
• 10-10-2009
RockyMarrone
try to post some code that will be better for the members here and then every body can help u out on that as u know code speaks more then thousands of words
• 10-10-2009
andy09
Assume "answer" is return value > 0 and i want to save
that value and kept doing it until i finish check all 3 number...then i retreat

Will pointer will do my trick? What is the rule of thumb when to use pointer? what pointer is good for?

I have a function definition that return back caller function...and action take place..and I have a for loop kept do until equal to 3... and everytime it return back a number...and kept doing it until equal 3. i want to save number every time return back caller function (testNibble) and kept doing it until = 3. below code is inside for loop

Code:

``` for (nibble = 0; nibble <=3; nibble++) {                                                                 if (choice =='f')                                 answer = testNibble(number, nibble, value); /* call function */                                                                 else if(choice =='r')                                                                                 answer = replaceNibble(number, nibble, value, readinNewVal, item, out); /* call function */                                                                                                 if ( answer > 0)                                         {                                                                                                                         c = &answer;                                         *c = answer;                                                                                 c = (answer | number );                                                                                     if (nibble >=3)                                               {                                                     c = (answer | number );                                               }                                         } }```
• 10-10-2009
RockyMarrone
Did u heard any thing call recursive functions from best of my knowledge if i m getting your problem correctly then

wiki recursive functions C/C++ may be it will help u
• 10-10-2009
quzah
Sounds like you want an array:
Code:

```int savedanswers[3] = { 0 }; ... for( x = 0; x < 3; x++ ) {     savedanswer[ x ] = getanswer(); }```
Otherwise, I'm not sure what it is you're trying to do, and you'll need to explain in greater detail what it is you're doing. Try writing the problem out in pseudo-code (real words) in small steps of what you're actually trying to do.

Quzah.
• 10-10-2009
RockyMarrone
Quote:

Originally Posted by quzah
Sounds like you want an array:
Code:

```int savedanswers[3] = { 0 }; ... for( x = 0; x < 3; x++ ) {     savedanswer[ x ] = getanswer(); }```
Otherwise, I'm not sure what it is you're trying to do, and you'll need to explain in greater detail what it is you're doing. Try writing the problem out in pseudo-code (real words) in small steps of what you're actually trying to do.

Quzah.

Hey bro he said he want to return every value in a loop kind of what i understood of the below quote
Quote:

have a function definition that return back caller function...and action take place..and I have a for loop kept do until equal to 3... and everytime it return back a number...and kept doing it until equal 3. i want to save number every time return back caller function (testNibble) and kept doing it until = 3. below code is inside for loop

• 10-10-2009
RockyMarrone
or i think he wants

Code:

``` int arr[3]; for(int i = 0; i < 3; ++i) {   arr[i] = function_returning_somevalue(const taking_some_value); }```
hey andy u want this kind of stuff or what
• 10-10-2009
quzah
Quote:

Originally Posted by RockyMarrone
Hey bro he said he want to return every value in a loop kind of what i understood of the below quote

I read what he said. Tell me how that's different than what I posted?

"have a function definition that return back caller function..." Ok, fine, you make a function that returns something. That's fine.

"and action take place" What's that supposed to mean?

"and I have a for loop kept do until equal to three..." Yeah, that's what I did.

"and everytime it return back a number..." Check.

"and kept going until it equal 3" Yeah you already said that.

"save number every time return back to caller" Yep, sticking it in an array.

"and kept doing it until = 3" Yeah you said that three times now.

Ok, so what's the point of you posting?

Quote:

Originally Posted by RockyMarrone
or i think he wants

All you did is copy what I just posted, with different variable names... Don't imply that I'm wrong then just copy what I post and say it's right. You look like an idiot when you do that.
[/edit]

Quzah.