473,387 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

what does exit(10); mean in C language program?

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. int main()
  3. {
  4.  int j=printf("Hello.");
  5.  return 0;
  6.  exit(10);
  7. }
Here in the above C program, what does exit(10) mean?
Oct 12 '12 #1
11 10012
Banfa
9,065 Expert Mod 8TB
it means exit the program and return a value of 10 to the operating system as the programs result.

What 10 might mean is operating system dependant the only number with a defined meaning is 0 which must be interpreted as success. Normally any non-zero number is interpreted as fail in some manner.
Oct 12 '12 #2
soli
3
I think "exit(10);" here is meaningless and unreachable, case the program return 0 before.
Oct 12 '12 #3
Banfa
9,065 Expert Mod 8TB
Sorry you're right I answered the question in your title not the question in your post.

In the posted code the exit(10); is unreachable and will never be executed because the return 0; will happen first.
Oct 12 '12 #4
Icyhot
6
Check this out for more details about the exit method.
Oct 12 '12 #5
i think its meaningless it's same as exit(0),exit(1)..if i m wrong then pls let me knw
Oct 13 '12 #6
sonu53
1
at starting of prog. there is int j = (print"hello");
here is i is of integer type and hello is of char type then how can it possible....??
pls explain mi in detail this program from top to bottom.
Oct 13 '12 #7
Rabbit
12,516 Expert Mod 8TB
@sonu, printf accepts a char* and returns an int. It's not returning the char* being passed to printf.
Oct 14 '12 #8
When return 0 will be encountered function returns to O.S. with value as 0. So the exit(10) will never be executed.
Oct 15 '12 #9
exit(10) i.e. any non zero value to exit() is considered as abnormal program termination.
Oct 18 '12 #10
donbock
2,426 Expert 2GB
The exit value can be tested by the entity (batch script, perl script, make, etc) that invoked the program. The meaning of any particular exit value depends on the program that returns it; but the implication of the exit value depends on how the invoking entity reacts to it.

FYI, the default behavior for make is to abort the build if any program returns with a nonzero exit value.

If you write a program that supports nonzero exit values then it is may be useful to print an explanatory error message to stderr before exiting. Printing the error message may be unconditional or you might choose to print it only if a command-line argument requests verbose output. Refer to the perror function for a means to print errors reported by Standard Library functions.
Oct 18 '12 #11
Is the code correct?
Oct 25 '12 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrey Mishenin | last post by:
While accessing MySQl data base by means of perl the value of variable $! sometimes equals " Resource temporarily unavailable". At the mean time everything works correct. What does that mean?...
2
by: pembed2003 | last post by:
Hi all, I recently saw a piece of code that looks like: class one{public: one(){} }; class two : public virtual one{public: two(){} }; class three : virtual public one{public: three(){} }; ...
4
by: pete | last post by:
I found it in the view source of a corporate website. <script Language="Javascript"> <!-- var keyMacro= ]; //--> </script>
12
by: opistobranchia | last post by:
I was on a job interview and the interviewer asked what "this" meant. I replied it represented this class like cout << a or cout << this.a then he asked what this meant if it was static? I...
6
by: **Developer** | last post by:
What does this mean: External component has thrown an exception. My program crashes after it leaves a subroutine. What I see during debugging is when I press F11 at the End Sub statement
7
by: Jake Thompson | last post by:
What does SIMENTRY mean as in ULONG SIMENTRY RemoveFolderItem( hSession, pszFolderID, pszItemID, pAsyncCtl, pRC ) is it necessary?
9
by: JoeC | last post by:
m_iWidth = (int)pBitmapInfo->bmiHeader.biWidth; m_iHeight = (int)pBitmapInfo->bmiHeader.biHeight; What does this mean? I have seen v=&var->member.thing; but what does it mean when you...
4
by: CodeTilYaDrop | last post by:
I am still pretty new to programming, and I sometimes can not figure something out. I am getting an error with this line in my program: Public void count_syllables(int count_syllables) I get...
0
by: steve | last post by:
What does it mean to set a value or April fools all year long :) http://beyondsql.blogspot.com/2008/03/sql-what-does-it-mean-to-set-value.html
1
by: rasmidas | last post by:
Hi, Could anyone please let me know what does it mean by the following statement in solaris shell scripting. $PROMPT " Select an option: " read ans db_option=${ans:=0} I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.