Thread: Weird return statement. Not exactly sure what it means. Can someone explain this?

  1. #1
    Registered User Mike Garber's Avatar
    Join Date
    Sep 2013
    Posts
    59

    Weird return statement. Not exactly sure what it means. Can someone explain this?

    Can someone explain what this return call is doing? This is an int isEmpty function that involves stacks.

    Code:
    int isEmpty( stack* myStack ){
    return mystack->front == NULL;
    }
    Is this some some sort of conditional statement combined with a return call?

  2. #2
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    It returned an boolean value.
    Think about like:
    Code:
    if (mystack->front == NULL) …
    Other have classes, we are class

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,111
    "myStack points to a "stack" struct. The pointer, "front" is a member of that struct. If "front" is set to "NULL" then it does not point to anything. The stack is empty, and the function returns a non-zero value (true). If "front" DID point to a valid address, then the function would return zero (false).

    The statement is not weird at all! You need to study more about both pointers and structs to understand this better.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can someone explain what __ means?
    By ens_leader in forum C Programming
    Replies: 2
    Last Post: 02-19-2008, 12:19 AM
  2. Can someone explain to me what this code means
    By Shadow12345 in forum C++ Programming
    Replies: 3
    Last Post: 12-22-2002, 12:36 PM
  3. explain this loop statement?
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 05-05-2002, 02:46 AM
  4. Can someone explain what this means??
    By JamMan in forum C++ Programming
    Replies: 6
    Last Post: 12-05-2001, 02:56 PM
  5. Can someone explain what the EXP(X) function means?
    By raptor2xtreme in forum C++ Programming
    Replies: 2
    Last Post: 11-07-2001, 12:19 AM

Tags for this Thread