0
diffrence between void and int
what is diffrence between void main and int main
3 odpowiedzi
+ 2
The return type is used to tell the computer how the program ended, so the return 0 which sits at the end is only ever invoked if the program gets to the end without breaking. If something else is returned it will be told otherwise. Void on the other hand doesn't allow for returned values.
+ 1
srry i am new .... plz explain in detail
+ 1
Fair enough. I'd advise reading about functions so you know was a return type is.
Long story short you can tell the program to start a function, it will do some things, and if it has a return type (so int, bool, float, etc. NOT void) it will bring a value back after finishing the function. If it is void, it will just do things in the function and return nothing, no return.
main itself is a function, the beginning of the program. While you're learning the bare bone basics you're fine to use void main and cut out the return 0; on the last line.