Solved

returning values

Posted on 1998-12-12
2
144 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

914 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now