Copyright
First published in Great Britain in 1997 by
Arnold, a member of the Hodder Headline Group,
338 Euston Road, London NW1 3BH
http://www.arnoldpublisher.com
Copublished in North, Central and South America by
John Wiley & Sons Inc.,
605 Third Street,
New York, NY 10158-0012
1997 William Buchanan
All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronically or mechanically, including photocopying, recording or any information storage or retrieval system, without either prior permission in writing from the publisher or a licence permitting restricted copying. In the United Kingdom such licences are issued by the Copyright Licensing Agency: 90 Tottenham Court Road, London W1? 9HE.
Whilst the advice and information in this book is believed to be true and accurate at the date of going to press, neither the author nor the publisher can accept any legal responsibility or liability for any errors or omissions that may be made.
British Library Cataloguing in Publication Data
A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of Congress
ISBN 0 340 70014 9
ISBN 0 471 85266 2 (Wiley)
Publisher: David Ross
Production Editor: James Rabson
Production Controller: Sarah Kett
Cover designer: Terry Griffiths
Printed and bound in Great Britain by J W Arrowsmith, Bristol
Preface
Specialization in software development is becoming a thing of the past. Previously many software developers specialized on software languages such as FORTRAN, C and Pascal. This was mainly because these languages allowed access to all the required functionality. In modern times with the move towards graphical user interface programming a developer must choose not only the required software language(s) but also the required set of development tools for a specific purpose. Typical decision might be to:
Minimize development time;
Create a usable interface (such as DOS, or Microsoft Windows or X-Windows, and so on);
Operate within critical timings (such as the use of fast code, or that DOS programs generally operate faster than Microsoft Windows programs, or that compiled programs generally work faster than interpreted programs);
Integrate with other software or systems (such as the integration with previous written software, different operating systems or with precompiled libraries);
Maintain the long-term development of the program (typical questions might be: will there be updates to the development tools; will the development company still be around in a few years?, and so on).
Typical modern development languages are C/C++, Visual Basic, Ada (especially in military applications), Java and Delphi. This book introduces C/C++ which can be used in C/C++ and Java development applications. Pascal is useful in developing Delphi and Ada applications. Visual Basic is used to write Microsoft Windows applications, and 80X86 Assembly Language programming is useful in writing extremely fast sections of code and in appreciating the operation of the PC.
The main objective of the text is to provide a single source of reference and learning material for most of the main technical programming languages. It can be used by undergraduates through a course of study from first year to final and from introductory tutorial work to advanced user interfaces and project work. It can also be used by professional developers with a knowledge of one or more of the software development language who wish to learn some, or all, of the others, or how these languages can be used in real-life applications.
The text splits into nine main sections:
Part A: Pascal/C programming gives an introduction to structured software development using Pascal and C.
Part B: C++ programming gives an introduction to object-oriented design with C++.
Part C: 80x86 Assembly Language programs gives an introduction to Assembly Language programming and PC architecture.
Part D: Visual Basic programming gives an introduction to the development of graphical user interfaces for Microsoft Windows.
Part E: HTML and Java programs show how to develop WWW-based pages and gives an introduction to Java.
Part F: DOS.
Part G: Windows 3.
Part H: Windows 95.
Part I: UNIX.
The text uses C and Pascal to provide a basic grounding in software development. These are used to show structured software development concepts, such as repetition, decision making and modular development. The more advanced concepts of object-oriented design is introduced with the C++ development. The Visual Basic section contains program examples which can be used to develop graphical user interface programs.
Many software development job advertisements now specify the requirement for a mixture of software languages on possibly several different operating systems. Software development has thus evolved to the point where it is possible to integrate different software tools to produce the required system. The user interface of a program might be developed using a graphical programming language such as Visual Basic and various specialized modules within the program could be developed in C/C++. In summary, in a changing employment market:
it isessentialto become multi-skilled in different areas and applications.
PART A
C/PASCAL
Introduction
1.1 Introduction
Software development has grown over the years from simple BASIC programs written on small hobby computers to large software systems that control factories. Many applications that at one time used dedicated hardware are now implemented using software and programmable hardware. This shift in emphasis has meant that, as a percentage, an increasing amount of time is spent on software and less on hardware development.
Electrical, electronic and software engineers require a great deal of flexibility in their approach to system development. They must have an understanding of all levels of abstraction of the system, whether it be hardware, software or firmware. The system itself could range from a small 4-bit central heating controller to a large industrial control system. In the development of any system the engineer must understand the system specification from its interface requirements, its timing requirements, its electrical characteristics, and so on.
The software that runs on a system must be flexible in its structure as the developer could require to interrogate memory addresses for their contents or to model a part of the system as an algorithm. For this purpose the programming languages C and Pascal are excellent in that they allow a high-level of abstraction (such as algorithm specification) and allow low-level operations (such as operations on binary digits). They have a wide range of applications, from commerce and business to industry and research, which is a distinct advantage as many software languages have facilities that make them useful only in a particular environment. For example, in the past, business and commercial applications used COBOL extensively, whereas engineering and science used FORTRAN.