Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

void function - return value

Status
Not open for further replies.

maggmich

Programmer
Nov 13, 2004
1
AT
Hello!

Why shouldn't I implement a return-value f. ex. "return(0)" into a void function?
I heard this once in terms of tidy programming.
f. i.:
Code:
void writeString(char *str)
{
  printf("%s",str);
  // return(0); ?????? I shouldn't! Why?
}

Yours
Jürgen
 
The way you return from a void function is simply by doing

Code:
void writeString(char *str)
{
    printf("%s",str);
    return;
}

--
 
Because it would be wrong and misleading. A function with a void return value does not return 0; it returns nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top