Solved

returning values

Posted on 1998-12-12
2
146 Views
Last Modified: 2010-04-02
When the main function is closed , we write return 0;
They say that the program returns 0 to dos. What is the theory behind it?what is IVT and how does it relate to program of c++.What distinguishes c++ from other programming languages?
0
Comment
Question by:shahid1
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 20 total points
ID: 1180003
You return an error code.  By convention 0 means your program worked.  Other values could mean an error occured.  Different values mean different errors (which number means which error is up to you).  Using this information programs which kick off your program can decide what to do next (example:a batch file).  This doesn't make sense for everything but does for a utility say.

IVT = ?  It's not in www.whatis.com.  IVT is VC help say InfoViewer Topic (the help system is divided into topics).  Other IVT = interrupt vector table (a jump table of where the CPU jumps in response to service each request).  Using a jump table in read/write memory allows you to patch the system interrupts.  You don't normally do that in C++ (but I guess you can on systems), it's normally an assembler type task.

C is a high level language with low level features (almost like a high level "assembler").  You can write readable high performance programs accessing low level resources.  C++ adds modern features (OO, templates, exceptions) to C.  Both languages leave it to the programmer to decide many things (you are not coodled), which is both good a bad (programmer has control but can easily mess up crashing the system/program etc)


0
 
LVL 4

Expert Comment

by:pagladasu
ID: 1180004
IVT in this context is Interrupt Vector Table - an array in low memory containing the addresses of the different Interrupt Service Routines. DOS programmers made use of this feature for customising the system, writing TSRs as well as computer viruses.
The return value actually will indicate the exit status of your program. In DOS, you can execute your program from a batch file and check the return value with the DOS batch programming keyword ERRORLEVEL. As far as I can remember, the return value of main() in DOS can be obtained by examining the AX register.
Thanks
pagladasu
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question