Geeks Talk

Prepare for your Next Interview




Can void be the return value of main Function

This is a discussion on Can void be the return value of main Function within the C and C++ forums, part of the Software Development category; Is it possible to declare the main() as void. Will this declaration of main function as void give me error? Someone who has experienced throw highlight on this....


Go Back   Geeks Talk > Software Development > C and C++

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-12-2006
Contributing Member
 
Join Date: May 2006
Posts: 73
Thanks: 0
Thanked 4 Times in 4 Posts
joel is on a distinguished road
Question Can void be the return value of main Function

Is it possible to declare the main() as void. Will this declaration of main function as void give me error? Someone who has experienced throw highlight on this.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-12-2006
Expert Member
 
Join Date: May 2006
Location: New York, USA
Posts: 118
Thanks: 0
Thanked 6 Times in 4 Posts
RyanJames is on a distinguished road
Re: Can void be the return value of main Function

It is not possible to declare main() function return value as void. This is because the default return value of main function in C is int and if one declares it as void it results in mismatch in declaration and so cannot be declared as void.
Reply With Quote
  #3 (permalink)  
Old 07-13-2006
Contributing Member
 
Join Date: May 2006
Posts: 73
Thanks: 0
Thanked 4 Times in 4 Posts
joel is on a distinguished road
Re: Can void be the return value of main Function

It was a nice explanation so is it that if one declare void in main() the program would throw redeclaration error that is a compile time error.
Reply With Quote
  #4 (permalink)  
Old 09-10-2007
Junior Member
 
Join Date: Jul 2007
Posts: 20
Thanks: 5
Thanked 8 Times in 6 Posts
pbchaudhari is on a distinguished road
Re: Can void be the return value of main Function

void main() works in the TC compiler but not in cc. why?
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Return Value of Functions janelyn C and C++ 3 09-24-2007 02:09 AM
Usage of function janelyn C and C++ 2 11-12-2006 03:11 PM
Type of Error for Variables not declared in function fred C and C++ 1 07-12-2006 05:31 PM
WebSphere V5.0 : Use search function Lokesh M Web Tools 0 06-02-2006 09:15 AM


All times are GMT -4. The time now is 01:36 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved