Need help with Function.

This is a discussion on Need help with Function. within the C Programming forums, part of the General Programming Boards category; Hello guys, I am doing a C Project. The thing where I am stuck at is, Comparing the returned value ...

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    16

    Need help with Function.

    Hello guys, I am doing a C Project.

    The thing where I am stuck at is, Comparing the returned value of a function with a zero. I don't know if it can be done like by comparing the function name with a zero directly. If we cannot do that how can we catch the returned value into a var (so that we can compare this to a zero).

    It will be really great if anyone can provide some idea if I am
    doing anything faulty.

    Best Regards,
    Kishore

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,535
    foo();
    Calls a function called foo

    if ( bar() == 0 )
    Calls a function called bar, and compares it's return result with 0

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Otherwise, you use the return value just like you assign any type:
    Code:
    int bar( void )
    {
        return 1;
    }
    
    int main( void )
    {
        int foo;
    
        foo = bar( );
        return 0;
    }
    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM

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