Everything about void data type in C and void main ()

787 views
0

Everything about void data type in C and void main ()

In: Engineering

void in a function definition means it doesn’t return a value. “void main()” means there’s a “main()” function, and it doesn’t return anything. It’s also wrong.

“main” is a special function name. It’s the starting point of a program and the code that gets called to get things started. It’s supposed to return an int to indicate whether the program did whatever it was doing successfully.

The operating system doesn’t know you declared it as void and still tries to use the return value, which is going to be some random thing in memory. This is not particularly harmful, but any code that calls your program might decide it had failed, or not, at random.