Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

returning values

Posted on 1998-12-12
2
Medium Priority
?
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 40 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

705 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