Thread: void non void function

  1. #1

    void non void function

    i'm so confused......when should or must i use void or non void function. and another question one star * and double star **
    how t use it ............Thank you very much

  2. #2
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    You should use void function, when you don't want to return "anything" from that function.

    About your second question 'one star or two':
    One 'star' means a Pointer, he points to a place on the memory.
    Two 'stars' means a Pointer that points to another pointer.

    if you be more specific on your question, we can help you more.

  3. #3
    i mean sometimes you still want to use or update the value in non void function but u dont have to return it so this makes me confuse

  4. #4
    Registered User Azuth's Avatar
    Join Date
    Feb 2002
    The function should generally be void if you're never going to want it to return a value. This does not stop the function from working with variables or other program information by way of pointers etc.
    Demonographic rhinology is not the only possible outcome, but why take the chance

  5. #5
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001


    What value?

    A value passed in?
    "He who makes a beast of himself, gets rid of the pain of being a man." Dr. Johnson

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    An example of a function that returns void.
    #include <stdio.h>
    void DumpInt(int);
    int main()
      int j = 10;
      printf ("But in main its %d\n", j);
      return 0;
    void DumpInt(int i)
      printf ("Your number is %d\n", i);
      i += 10;
      printf ("Your number is now %d\n", i);
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  7. #7
    Registered User Cela's Avatar
    Join Date
    Jan 2003
    >>when should or must i use void or non void function.
    You use void when all you want is the side effect
    void display(int num)
      printf("The number is %d\n", num);
    As opposed to wanting a direct change
    int add(int a, int b)
      return a + b;

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, 03:07 AM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  4. Pls repair my basketball program
    By death_messiah12 in forum C++ Programming
    Replies: 10
    Last Post: 12-11-2006, 05:15 AM
  5. Replies: 5
    Last Post: 02-08-2003, 07:42 PM