1

So, my teacher said that in c standard you have to put a return at the end of void functions, after a lot (and I mean A LOT) of research I've found nothing, am I missing something or is the person who doesn't respect any standard inventing that thing?

Comments
  • 0
    I know I can do it, and one of my previous teachers (the only one who actually taught me something) always told me to avoid it, since it leads to bad programming habits (like returning in the middle of the function)
  • 4
    So your research has returned void? Sorry I'll see myself out...
  • 0
    Basically it means "nothing" or "no type"

    There are 3 basic ways that void is used:

    Function argument: int myFunc(void) -- the function takes nothing.

    Function return value: void myFunc(int) -- the function returns nothing

    Generic data pointer: void* data -- 'data' is a pointer to data of unknown type, and cannot be dereferenced

    Note: the void in a function argument is optional in C++, so int myFunc() is exactly the same as int myFunc(void), and it is left out completely in C#. It is always required for a return value.

    EDIT: SO to the rescue.
  • 0
    @rootshell
    I know what void means, I was talking about the empty return at the end of the function 😅
  • 0
    It's standard, but not necessary. It marks the end of a function much like

    // End of dick sucking function

    Does
  • 0
    @SimplyAero Well that is rather pointless yeah since it shouldn't return anything.
Add Comment