return decimal number back caller function

This is a discussion on return decimal number back caller function within the C Programming forums, part of the General Programming Boards category; Hi, I am new to pointer..and trying to use pointer in my program. here is what I want pointer does.... ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    6

    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 help.. I am new to C, and new to pointer...learn how to use it...any good links that help me...

    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 ?

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    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

  3. #3
    Registered User
    Join Date
    Oct 2009
    Posts
    6
    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
    and use computation... please help my code...if pointer is the way to go?


    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 );
    
    					      }
    
    					}
    
    
    
    
    }
    Last edited by andy09; 10-10-2009 at 07:30 AM.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Did u heard any thing call recursive functions from best of my knowledge if i m getting your problem correctly then

    google it

    wiki recursive functions C/C++ may be it will help u

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    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.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    Quote Originally Posted by quzah View Post
    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
    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

  7. #7
    Registered User
    Join Date
    Oct 2009
    Location
    While(1)
    Posts
    377
    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

  8. #8
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by RockyMarrone View Post
    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?

    [edit]
    Quote Originally Posted by RockyMarrone View Post
    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.
    Last edited by quzah; 10-10-2009 at 08:13 AM.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Replies: 8
    Last Post: 03-10-2008, 11:57 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 01:08 AM
  5. opengl program as win API menu item
    By SAMSAM in forum Game Programming
    Replies: 1
    Last Post: 03-03-2003, 06:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21