Please can anybody tell me the difference in return 0 and system ("pause");

Please can anybody tell me the difference in return 0 and system ("pause");

return 0 means the value 0 (usually some type of int) is returned from a function to the caller of the function.

system() is a library function that makes calls to OS commands/programs. system("pause") calls the "pause" command in DOS/Windows. Run the pause command in a command shell to see what it does.

Please can anybody tell me the difference in return 0 and system ("pause");

Can you tell me the difference between the sky and the earth...!!!..??
your question and my question are similar...,..They have no relation to differentiate them..

Can you tell me the difference between the sky and the earth...!!!..??
your question and my question are similar...,..They have no relation to differentiate them..

the sky is what holds the snow and water and also the hanging place for the big light mean while the earth is the gruond on which we will walk and do all other
things .

Can you tell me the difference between the sky and the earth...!!!..??
your question and my question are similar...,..They have no relation to differentiate them..

the sky is what holds the snow and water and also the hanging place for the big light mean while the earth is the gruond on which we will walk and do all other
things .

I think the both of you should seriously consider your motives for "attempting" to even participate in this forum. Stop wasting the valuable time of members who treat this forum with decorum and respect.

the sky is what holds the snow and water and also the hanging place for the big light mean while the earth is the gruond on which we will walk and do all other
things .

in the same way:

system("pause");

will cause the black dos window (where you see your output) to be paused untill you press any key.
But the

return 0;

statement is a type of statement which is written at the last of any function which has its return type as integer(commonly).This is like a command saying "NOTHING TO DO" at the last of the functions definition.

Comments
What the hell are you talking about?
return 0;

statement is a type of statement which is written at the last of any function which has its return type as integer(commonly).This is like a command saying "NOTHING TO DO" at the last of the functions definition.

What? Listen, I already answered the OP's original question and your answer is plain wrong. The return keyword in C means that the function is returning a meaningful value back to the caller of that function (in well written functions).

Saying something like "it's a command saying "NOTHING TO DO" is WRONG!!! Have you ever checked the return value of the fopen() function and what it potentially means? If you assumed that the return value of this function means "nothing to do", then you may be in for a rude shock.

It's been a month since I began participating in this forum and I cannot believe some of the misnomers that are put forward.

Sheesh!!!

In case of main function, if i forgot to write return 0; at the last, GCC compiler generates no error , what i found is that.
So I said that return 0; means nothing to do.
I know about the importance of return statement in other built-in functions and user defined functions.
But in case of main function if return 1; or other would have some meaningful sense, but return 0; has no sense.

In case of main function, if i forgot to write return 0; at the last, GCC compiler generates no error

If you rely on the compiler to point out every problem in your code, you will spend more time with the debugger than if you know the problem areas that go undiagnosed by compilers and always write code with your brain switched on. :) Coding in C takes more work because the compiler does not try to protect you from every possible mistake.

But in case of main function if return 1; or other would have some meaningful sense, but return 0; has no sense.

A return value of 0 from main means success. Unless you compile with the std=c99 switch in gcc, omitting the return statement invokes undefined behavior because main has to return an int. If you do not explicitly return a value, the value that gets returned is what we call indeterminate. The value cannot be predicted and the resulting behavior of the calling process in turn cannot be predicted.

If you compile with std=c99, you can omit the return statement because C99 implicitly returns 0 if execution falls off the end of main without an explicit return statement. Otherwise, return 0; is a very good idea. If it still makes no sense to you, try return EXIT_SUCCESS; and include <stdlib.h>. That might look like more work is being done. ;)

Comments
Wise words indeed, there is no safety netting.
This article has been dead for over six months. Start a new discussion instead.