LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-03-2011, 01:38 AM   #1
roshan moodbidri
LQ Newbie
 
Registered: Jun 2011
Posts: 1

Rep: Reputation: Disabled
return and exit in C


What are the uses of return 0, return 1 and exit statements in C
 
Old 06-03-2011, 02:10 AM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by roshan moodbidri View Post
What are the uses of return 0, return 1
So that the function can provide information to whatever called it.
Quote:
and exit statements in C
To exit the program...
Exiting with 0 should indicate that the program exited normally. A non-zero exit should indicate some sort of abnormal termination.

Evo2.
 
Old 06-03-2011, 09:38 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by evo2 View Post
So that the function can provide information to whatever called it.
And in the case of the main() function, the return value is used as the exit code.
 
Old 06-03-2011, 05:59 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 06-03-2011, 06:13 PM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
Do we have a bucket for homework? ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Command To Close Window and Return Exit Code jagooch Programming 3 01-02-2009 03:33 AM
Exit vs Return JimRobinson Linux - Newbie 3 07-24-2008 12:26 PM
dhcpcd in Slackware 11.0 does not return any exit codes other than 0? Ken-ji Slackware 1 04-01-2007 06:55 PM
program exit return 0 or 1? blackzone Programming 4 07-20-2006 05:00 AM
Exit with Return nopcoder Programming 0 12-27-2005 10:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration