Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test

Home » Forum » x-Forum » Question

Does the author of the C Programming tutorials actually know what they are talking about?

Section 5.1.2.2.1 of the C Standard (ISO/IEC:9899) States that the main function is required to return an integer, yet the hello world tutorial shows void main, which is 100% incorrect. If you are going to teach, atleast know what you are teaching.

Posted by climjark 2019-10-17 10:58:46

Thanks for posting it.

Actually we know it should be int but it is not mandatory to return int value. 

You will see different code snippet returning void and int. 

We want to show code with dfferent scenarious. You may see main() returning int in different  tutorials.

Please check C MCQS




C++ user image Admin posted 2019-10-17 11:21:55

Actually it is required. If it is not a function returning an int, then you simply are not writing C Code. The standards are not subjective. They are defined to outline what a programming language consists of. It is mandatory because the C runtime uses that return value as a parameter to the exit function within the runtime to properly exit your code. This is linked in at compile time. 

C++ user image climjark posted 2019-10-17 11:50:39

Teachers are suppose to be preparing students for the future, but it seems like you are preparing them for the past. conio.h is not in the language and has never been in the language. It is a DOS header file that has not seen the light of day in a program since the early 1990s. And my bad only one of the multiple choice questions actually compile (it uses int main.... go figure)

C++ user image climjark posted 2019-10-17 11:56:32

I agree 'conio.h' should be removed. We will also change the return type of main() wherever needed. We appreciate your feedback and will be more than happy if you come up with other issues on our portal.

C++ user image Admin posted 2019-10-17 15:18:33

Please login to comment

Log In


Ask New Question