I've noticed that some programs always have a code snippet, which is always executed last, which receives as a parameter a number, usually
For a better understanding, I put this example of a PyQt application:
#-*- coding: utf-8 -*- import sys from PyQt4 import QtGui app = QtGui.QApplication(sys.argv) win = QtGui.QWidget() win.show() ret = app.exec_() #quando eu fecho a aplicação, retorna 0 print ret # todos os tutoriais que li, ensinam a colocar essa linha # com esse retorno sys.exit(ret)
In C, I already noticed that the
int main method usually returns a
int . Generally, they return
0 (I do not know if it's related too).
In some PHP scripts, I have already seen
1 being returned also at the end of a program's execution.
As for example
Anyway, I'd like to know what these numbers mean, which are usually defined in the "last line" of a program's code.
What are the meanings of ending a program with
1should be used? Or are there other numbers, with specific meanings?
What is the name given to this kind of output from the application? I read in some related answer here on the site that the term state code , but I'm not sure if that is it.