+ 1

What is the use of return 0 in the code...?

#include <stdio.h> int main(){ printf("hello akash"); return 0; }. It works even without the return statement and its argument also not making any difference .... Pls someone make it clear to me....

11th Jun 2019, 1:13 PM
Akash C R
Akash C R - avatar
2 odpowiedzi
+ 4
Returning 0 signifies a successful execution and EXIT_FAILURE indicates an error. If you don't specify a return value, your program will implicitly return some unknown value to the system (in C99/C11 it implicitly returns 0). I don't know what operating system you're using but on Linux, you can check the return value of a program after its execution by typing: $? Example: int main(void) { puts("Hello, World"); return 7; } ________________________________ > ./helloworld > echo $? > 7 ________________________________ It's good practice to always return 0 on successful execution and the main function should never be declared as void main().
11th Jun 2019, 3:01 PM
Cluck'n'Coder
Cluck'n'Coder - avatar
+ 1
Thanks bro
11th Jun 2019, 4:56 PM
Akash C R
Akash C R - avatar