+ 20

What happen when we not use void main?

4th Apr 2018, 11:48 AM
Puneet Bhardwaj
Puneet Bhardwaj - avatar
64 Answers
+ 38
Void return type for main has never been part of the C standard. Use int main. As stated here: http://www.stroustrup.com/bs_faq2.html#void-main
4th Apr 2018, 12:42 PM
Hatsy Rei
Hatsy Rei - avatar
+ 13
main() function runs your program. Without it there is nothing to do. You can use int main() instead of void main() if you want the program to return a value.
4th Apr 2018, 12:00 PM
Akib
Akib - avatar
+ 8
There will be no entry point to the programe
4th Apr 2018, 6:18 PM
Piyush
+ 8
404 NoT found
7th Apr 2018, 12:43 PM
Apple 🍏🇺🇿
Apple 🍏🇺🇿 - avatar
+ 7
The program simply won't start. It is useful for creating implementation of header files.
4th Apr 2018, 11:51 AM
Bartosz Pieszko
Bartosz Pieszko - avatar
+ 7
nothing will be executed .
8th Apr 2018, 7:16 PM
Anon Fox
Anon Fox - avatar
+ 6
we can use int main also. but there should be main function in our program. The C program is designed in such a way that the execution starts only from a main function. so if you don't give any main function the execution won't happen and the program will not run . Normally we use void run as our simple program does not require to return any value.
5th Apr 2018, 6:17 AM
அபிஷேக் அபி
+ 4
Since the execution of any program starts from main() function it is must for any program. If you do not used main() in your program, the program won't be executed. And we know that every function returns a value, it is necessary to write "void" indecating that the function will not return any value. You may use int.
4th Apr 2018, 4:02 PM
Nashat
Nashat - avatar
+ 4
main() is similar to any other kind of function , the difference is , usually other function are user defined but main() is built in function which helps is starting the program execution.
4th Apr 2018, 8:00 PM
Chandan singh
Chandan singh - avatar
+ 4
I think we use Void main() in turbo c++...which is not used now !! so using void main() in C++ 11 will cause an error !!
5th Apr 2018, 3:50 AM
I'm_Groot
I'm_Groot - avatar
+ 4
Value stored in memory will be used if you don't use it.
5th Apr 2018, 10:02 AM
Kartikey Kumar
Kartikey Kumar - avatar
+ 4
main() is the main method or behaviour of the program which defines how or what task the program has to perform you should use int main() if you want the program to return a value as stated in the courses but as far as i know void main() can be used when you don't want the program to return a value I don't have a lot of knowledge about c proggraming but i have a little through the sololearn course so, please correct me if i am wrong anywhere
6th Apr 2018, 8:13 AM
Devansh Gupta
Devansh Gupta - avatar
+ 4
your program starts executing from main() function. If you wouldn't use main the program won't run.
7th Apr 2018, 8:16 AM
FAISAL ANSARI
FAISAL ANSARI - avatar
+ 3
in the very old times, the main() in C was always void. it works even here. but since I was not in the C language development loop, and missed when int became a standard. https://code.sololearn.com/ci7g0CdGa4ja/?ref=app
4th Apr 2018, 9:07 PM
yuri
+ 3
First of all main() method is compulsory in any programme (as the programme starts execution from main() method) void is used because main() method does not return under normal circumstance but if you want to return any values you are free to use int main()......... so we use void main() { }
5th Apr 2018, 11:34 AM
SAI RAM M
SAI RAM M - avatar
+ 3
A C program can run even without any return type as int will be treated as default one. As for not using a main() in a program, the program will not execute but we can use such for header implementations...
5th Apr 2018, 12:51 PM
Tushar Patil
Tushar Patil - avatar
+ 3
it will shows the error
6th Apr 2018, 12:28 PM
Afzal
+ 3
void is return nothing and main is also returned type () function but it depends upon the function calling . If you not use main () function then operating system will not able to execute the programme so use there int main () function.
8th Apr 2018, 2:46 AM
Soft_aditya
Soft_aditya - avatar
+ 3
Program execution starts with main function so its mandatory that every program should have main function. only choice is whether to use void or int
9th Apr 2018, 6:44 AM
Nitin Pote
+ 2
main is a function and if you do not use viod your compiler show u an error
5th Apr 2018, 9:46 PM
Mohamad Shamsi
Mohamad Shamsi - avatar