Solved

returning values

Posted on 1998-12-12
2
143 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
Comment Utility
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
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

771 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

11 Experts available now in Live!

Get 1:1 Help Now