By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,497 Members | 2,010 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,497 IT Pros & Developers. It's quick & easy.

What is the purpose of the keyword void in a function declaration ?

P: 4
This is a question in my text book, and the answer is-
The keyword void in a function declaration has a significant purpose.When the return type of a function is void , that means the function doesn't return anything.Thus we can say that the purpose of specifying the return type void is that it doesn't return anything.

Please explain the answer.
Nov 18 '08 #1
Share this Question
Share on Google+
4 Replies

P: 13,264
What do you not understand about it?
Nov 18 '08 #2

Expert Mod 5K+
P: 9,197
You have to remember that a function is an instance of its return type. That is, a function that returns an int becomes an int when you call the function. The compiler knows this. Therefore, you can use the function call as an int.

The void return says the function is not an instance of anything. In techno-speak a void return means the function cannot be used as an r-value.
Nov 18 '08 #3

Expert 100+
P: 2,415
A function prototype declares the type of the return value of a function. It also declares the number and types of the function parameters. "Void" may appear in either context. Which usage of "void" are you asking about?
Expand|Select|Wrap|Line Numbers
  1. void foo(int arg);
  2. int bar(void);
Nov 18 '08 #4

P: 37
While Function Declaration u must specify the return value Or Otherwise

it will Take as integer

if programmer wants to be function should not Return value to calling function

they must specify VOID keyword

This is usage the void while function declaration
Nov 19 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.