Search
 
SCRIPT & CODE EXAMPLE
 

C

difference between int main() and void main()

Sometimes we use int main(), or sometimes void main(). Now the question comes
into our mind, that what are the differences between these two.

The main() function is like other functions. It also takes arguments, and 
returns some value. One point we have to keep in mind that the program starts 
executing from this main() function. So the operating system calls this 
function. When some value is returned from main(), it is returned to operating
system.

The void main() indicates that the main() function will not return any value, 
but the int main() indicates that the main() can return integer type data.
When our program is simple, and it is not going to terminate before reaching
the last line of the code, or the code is error free, then we can use the 
void main(). But if we want to terminate the program using exit() method, 
then we have to return some integer values (zero or non-zero). In that 
situation, the void main() will not work. So it is good practice to use 
int main() over the void main().
Comment

difference between int main() and int main(void)

So the difference is, in C, int main() can be called with any number of 
arguments, but int main(void) can only be called without any argument.
Although it doesn't make any difference most of the times, using
“int main(void)” is a recommended practice in C.
Comment

PREVIOUS NEXT
Code Example
C :: hello world in c language 
C :: i2c scanner 
C :: c code to algorithm converter online 
C :: website how to solve c programming questions 
C :: C Variable Byte Sizes 
C :: c triangle check if triangle is 90 degrees 
C :: default password raspberry pi 
Dart :: debug banner flutter 
Dart :: How to attach a FloatingActionButton to the AppBar 
Dart :: flutter get current date 
Dart :: how to change input text color in flutter 
Dart :: How to center AlertDialog FlatButton in Flutter 
Dart :: Keyboard Pushes Text Fields off screen flutter 
Dart :: color of status bar flutter 
Dart :: rotate IconButton flutter 
Dart :: flutter showsnackbar 
Dart :: date now dart 
Dart :: flutter linear progress indicator height 
Dart :: alertdialog flutter outside click disble 
Dart :: string to double fultter 
Dart :: flutter create app command 
Dart :: get only time from datetime in dart 
Dart :: flutter text 
Dart :: flutter snackbar duration 
Dart :: sizedbox flutter 
Dart :: chips in flutter 
Dart :: dart char is uppercase 
Dart :: android studio emulator blue screen windows 10 
Dart :: flutter check if drawer is open 
Dart :: set minus padding in flutter 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =