473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

what does it mean by VOID DOESNT RETURN ANY VALUE in C?

dear friend.
I am also a beginner. I have a lil programming experience? so i am not to familiar with the technical terms even though everyone explains the answers with lots of technical and programming terms. it would be kind enough if anyone please answer without hard and technical word. please remember ur first days.

1. what does it mean by VOID RETURNS NO VALUE?
2. why and when do i need RETURN NO VALUE?(APPLICATION)
3. if the coding is wrong then the compiler will tell me that there is a problem....so why should I myself have to pre-define that I want RETURN 0 or RETURN 1?

please give me some example...let me be a programmer....thanks
Sep 28 '13 #1
5 3659
weaknessforcats
9,208 Expert Mod 8TB
All void means is no type. Void is used in several places only one of which involves a return.

Is this a homework problem? I am not supposed to be doing your homework for you.
Sep 28 '13 #2
this is not homework....please help...m trying to learn c myself.....
Sep 28 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
OK.

void means no type.

When you do this:

Expand|Select|Wrap|Line Numbers
  1. int x = 10;
the compiler sees that it has to create an int variable named x and initialize it with the integer 10. Since is also an int, the compiler has no problem doing this.

But if the code is:

Expand|Select|Wrap|Line Numbers
  1. int x = fx();
  2.  
then the compiler needs to initialize x to the value returned by the function fx(). So does fx() return an int? To answer that the compiler looks at the function prototype:

Expand|Select|Wrap|Line Numbers
  1. int fx();    
and sees that fx() does return an it. So to get the value of the returned int, the compiler calls the function and takes the answer returned by the function and stores it in the in x.

However, if the compiler sees:

Expand|Select|Wrap|Line Numbers
  1. void fx();
it knows that no value is returned by fx() so the code:
Expand|Select|Wrap|Line Numbers
  1. int x = fx();
  2.  
can't possibly work and you get an error trying to compile it.

The way professionals view this is by saying " a function is an instance of its return type". A function that returns an int becomes an int value after the call. In the case of a function returning void, it becomes no type after the call.

In all cases a function that returns void cannot be used on the right side of an assignment operator. That is, the function cannot be an RVAL.
Sep 29 '13 #4
stdq
94 64KB
Sometimes, a function needs to return some value to the callee (the function that called it), and sometimes it doesn't. In this last case, the returned type is specified to be of type void. For example, a function that prints a menu might not need to return anything:

Expand|Select|Wrap|Line Numbers
  1. void printMenu( void )
  2. {
  3.     // print the options for the user
  4. }
The first void above specifies the return type of function printMenu. The second void specifies something else: it doesn't receive anything from the callee to perform its function.

What error are you getting with your compiler?

Best,
stdq
Sep 29 '13 #5
So does it mean

1. If ithere is void main then there shud not be any variable to take the value from the user.
2. If there is int main or only main then i can assign variable to collect the value.
3. So is it purpose of using void to make the compiler compile faster?
4. And when we use void we shud not use RETURN 0; and finally
5. When do we use RETURN 1.

Guys im asking too much ques coz i dont have any proper guide line. Please suggest me any book where i can learn c from zero.
Thanks a lot for your kind reply
Sep 29 '13 #6

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

Similar topics

1
by: Charles Hixson | last post by:
I'm getting a list that I build which when printed is displaying, well, e.g.: d = << , 'Do', 'not', 'remove', 'thi', '.', ] >> Clearly I have a problem with the truncation of the final this, but...
2
by: Don | last post by:
What does the onfocus value of "this.select()" do in the following <input...> tag? <input type=text name="img" size=20 onfocus="this.select()" value="http://" tabindex=7> Thanks, Don ...
7
by: Bruce Sam | last post by:
Is this a pointer array of function?If I was wrong,what does it means?
6
by: wintaki | last post by:
Given int x; What does x evaluate to? If x is 0, it equals 0x31, the ascii value of '1'. So for some reason, x evaluates to *(y+x) where x is a non pointer/array type.
1
by: alex14 | last post by:
Hi could someone please tell me what the double colons :: in perl scripts mean and what do they do? kind regards alex
2
by: SMichal | last post by:
Hi, I'm starting from my application simple bat data...test.bat. This file (test.bat) should start another aplication app.exe. I'm starting the test.bat from my application with Start() method of...
9
by: plusk1008 | last post by:
I have finals next week and I am stuck on one question on my review sheet for excel. So once again I beg: Please, please, please, please, please, please, please, please, please, please someone help...
2
by: mantrid | last post by:
in some php script ive seen $something==@$somethingelse whereas something==$somethingelse works the same what does the use of the @ do? Sorry if this is a stupid question
1
by: Daniel Brower | last post by:
I found documentation that uses the ^ notation after a type name. What does that notation mean? Daniel
1
by: Monica Pnade | last post by:
what does /^/ mean in perl?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.