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

2.58K views

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

In: Engineering

Anonymous 0 Comments

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.

You are viewing 1 out of 1 answers, click here to view all answers.