Thread: Return Statement

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    The Nice Guy
    Join Date
    Sep 2004
    Posts
    19

    Return Statement

    Ive have been reading several books regarding this topic, and all books state that the return statement can only return one value of result.

    How does this happen when you can return something like this to the user:


    *********
    * 222222 *
    *********

    Is that above a single result?

    Also, I see some programs having the void function like this:

    int
    main(void)
    {
    // Block of Code
    }

    How can this be void when it prints something on the screen?

    Okay, here is a code from the book:

    Code:
    void
    sperate(double num, char *signp, int *wholep, double *fracp)
    {
              double magnitude;
    
              if(num < 0)
                        *signp = ' - ';
              else if(num == 0)
                        *signp = ' ';
              else
                        *signp = ' + ';
    
              magnitude = fabs(num);
              *wholep = floor(magnitude);
              *fracp = magnitude - *wholep;
    }

    Now, in the above code, it says void, meaning this function does not return a result??? but it does, doesnt it? That what im getting confused about.
    Last edited by Daveo; 11-06-2004 at 04:44 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C or C++
    By AcerN30 in forum Game Programming
    Replies: 41
    Last Post: 05-30-2008, 06:57 PM
  2. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  3. C++ FTP class won't work
    By lord mazdak in forum C++ Programming
    Replies: 8
    Last Post: 12-18-2005, 07:57 AM
  4. sort linked list using BST
    By Micko in forum C Programming
    Replies: 8
    Last Post: 10-04-2004, 02:04 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 10:01 PM