+ 1

Why we can not use void instead of int to a main function

21st Mar 2017, 4:51 AM
Rishika Sharma
Rishika Sharma - avatar
3 ответов
+ 15
Data type void for main function has been slowly deprecated, since main functions should return values to the system.
21st Mar 2017, 4:57 AM
Hatsy Rei
Hatsy Rei - avatar
+ 2
void main() or getch() are from old/outdated C/C++ implementations. You should not use them. You should use int main() and return a value to the operating system to indicate whether your program has exited normally. getch() is function from conio.h which is MS-DOS library. It's not part of C/C++ standard library so you shouldn't use it. You can use getchar() instead.
21st Mar 2017, 5:14 AM
hdo
hdo - avatar
0
can I use getch in c++?
21st Mar 2017, 5:04 AM
Rishika Sharma
Rishika Sharma - avatar