When I use void main in the code it compiles successfully but gives an runtime error on gcc compiler..But when void is replaced by int then it doesnot show any errors.What is the reason behind this behaviour?

GCC doesn't support void main, therefore any use of it invokes undefined behavior. More specifically, if the compiler doesn't support void main then the code it produces could be very wrong or dangerous.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.