Thread: Void

  1. #1
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321

    Void

    Hi ppl.
    I've been lookin through the tuts on this website and have come accross the statement "void" alot.
    Can somebody please tell me what is this statement, if it is one and what use is it to me, and if it is any use, how would i use it?
    Thank you in advance...

  2. #2
    C / C++
    Join Date
    Jan 2006
    Location
    The Netherlands
    Posts
    312
    it means something like "empty":

    Code:
    void myFunction(void) // function doesn't return something and it doesn't accept any arguments
    {
    
    }
    
    function call: myFunction();
    Code:
    int myFunction(int value) // function returns something and accepts an integer.
    {
           return (value+2); // by example
    }
    
    function call: int x = myFunction(3); // by example
    Operating Systems:
    - Ubuntu 9.04
    - XP

    Compiler: gcc

  3. #3
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    oh, thank you

  4. #4
    Algorithm engineer
    Join Date
    Jun 2006
    Posts
    286
    void alone is the same as writing no arguments at all. function(void) means that function doesn't take any arguments. If you write void* it means a pointer, rather than writing int* which means a pointer to an int, or char* which means a pointer to a char. void* is just a pointer, not to any specific type. If you are going to have a function that doesn't return anything you must use void function.

  5. #5
    Sanity is for the weak! beene's Avatar
    Join Date
    Jul 2006
    Posts
    321
    kk, thanks for all of your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  3. game window rejected painting !
    By black in forum Windows Programming
    Replies: 4
    Last Post: 03-27-2007, 01:10 AM
  4. msvc just ate one of my source files
    By Eber Kain in forum C++ Programming
    Replies: 6
    Last Post: 07-01-2004, 05:40 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM