+ 1

Why we use int main() can we use another data type ? like float main() char main() if yes then why??

13th May 2019, 4:09 AM
Imran Yasin
Imran Yasin - avatar
2 Antworten
+ 6
The short answer, is because the C++ standard requires main() to return int. As you probably know, the return value from the main() function is used by the runtime library as the exit code for the process. Both Unix and Win32 support the concept of a (small) integer returned from a process after it has finished. Returning a value from main() provides one way for the programmer to specify this value.
13th May 2019, 4:57 AM
Clement Sam
+ 3
You can also try it on Code playground to see that the other data types don't work.
13th May 2019, 5:25 AM
Sonic
Sonic - avatar