0
What is the difference between void main and int main??
2 Answers
+ 4
void main and int main both are functions but if you use in main it should have return value 0 but if your function does not have return type or value you can use void main or simply both are used in the same way but void does not have any return value.
eg:
int main(){
cout<<"hello world!";
return 0;
}
void main(){
cout<<"hello world!";
}
as you can see in the above program both have output hello world! but the first program have return 0 which is return type for int main but void main does not have any return type or value.
- 1
A program that run without error should return 0 and if it return another value it mean that there is an error