Function call

This is a discussion on Function call within the C Programming forums, part of the General Programming Boards category; I have a question about calling a function from within an if statement. The prototype of the function is as ...

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    12

    Function call

    I have a question about calling a function from within an if statement.

    The prototype of the function is as follows:

    BOOKPTR BOOKSEARCH(BOOKPTR, int, int);

    The function call is as follows:

    if (mat = 1 && ITEM_ID != NULL)
    {
    BOOKPTR BOOKSEARCH(BOOKPTR BHead, int ITEM_ID, int mat);
    }

    and the function definition is as such:

    BOOKPTR BOOKSEARCH(BOOKPTR BHead, int num, int mat)
    {
    . . .

    When I run the program, it just skips over the function call. The debugger hits the opening brace and then the closing brace and goes on to execute the else if statement Can anyone tell me why??

  2. #2
    Registered User ivandn's Avatar
    Join Date
    Oct 2001
    Posts
    49

    Exclamation

    From what you have said, I believe the function call should look more like the following:

    if (mat = 1 && ITEM_ID != NULL)
    {
    BOOKPTR x = BOOKSEARCH(BHead, ITEM_ID, mat);
    }
    Ivan

  3. #3
    Registered User pinko_liberal's Avatar
    Join Date
    Oct 2001
    Posts
    284
    if (mat = 1 && ITEM_ID != NULL)
    {
    BOOKPTR BOOKSEARCH(BOOKPTR BHead, int ITEM_ID, int mat);
    }

    if you really wrote the above in your program and it compiled , its time you got a decent complier .
    ftp://ftp.xraylith.wisc.edu/pub/khan...32/gcc-2.95.2/

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,439
    > if (mat = 1 && ITEM_ID != NULL)
    if (mat == 1 && ITEM_ID != NULL)
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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. Troubleshooting Input Function
    By SiliconHobo in forum C Programming
    Replies: 14
    Last Post: 12-05-2007, 06:18 AM
  4. Replies: 28
    Last Post: 07-16-2006, 11:35 PM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

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