Practical C++ Programming

Total Page:16

File Type:pdf, Size:1020Kb

Practical C++ Programming Practical C++ Programming Steve Oualline O'Reilly & Associates, Inc. Beijing · Cambridge · Köln · Paris · Sebastopol · Taipei · Tokyo Page iv Practical C++ Programming by Steve Oualline Copyright © 1995 O'Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Editors: Adrian Nye and Dale Dougherty Production Editor: Nicole Gipson Printing History: August 1995 First Edition. January 1997: Minor corrections. Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks and The Java Series is a trademark of O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. This book is printed on acid-free paper with 85% recycled content, 15% post-consumer waste. O'Reilly & Associates is committed to using paper with the highest recycled content available consistent with high quality. ISBN. 1-56592-139-9 [12/98] Page v Table of Contents Preface xv I: The Basics 1 1: What Is C++? 3 3 A Brief History of C++ 3 C++ Organization 4 How to Learn C++ 6 2: The Basics of Program Writing 9 Programs from Conception to Execution 12 Creating a Real Program 13 Creating a Program Using a Command-Line Compiler 13 Creating a Program Using an Integrated Development Environment 16 Getting Help in UNIX 32 Getting Help in an Integrated Development Environment 33 Programming Exercises 33 3: Style 35 Comments 36 C++ Code 4 41 Naming Style 42 Coding Religion 43 Indentation and Code Format 43 Page vi Clarity 44 44 Simplicity 45 Consistency and Organization 46 Further Reading 46 Summary 46 4: Basic Declarations and Expressions 49 The Elements of a Program 49 Basic Program Structure 50 Simple Expressions 51 The cout Output Class 53 Variables and Storage 53 Variable Declarations 54 Integers 55 Assignment Statements 56 Floating Point Numbers 57 Floating Point Versus Integer Divide 58 Characters 59 Programming Exercises 60 Answers Chapter Questions 61 5: Arrays, Qualifiers, and Reading Numbers 63 Arrays 63 Strings 64 Reading Data 67 Initializing Variables 69 Multidimensional Arrays 70 Types of Integers 72 Types of Floats 74 74 Constant and Reference Declarations 74 Qualifiers 76 Hexadecimal and Octal Constants 78 Operators for Performing Shortcuts 78 Side Effects 79 Programming Exercises 82 Answers to Chapter Questions 82 Page vii 6: Decision and Control Statements 85 if Statement 85 else Statement 87 How Not to Use strcmp 88 Looping Statements 88 while Statement 88 Break Statement 91 continue Statement 92 The Assignment Anywhere Side Effect 92 Programming Exercises 94 Answers to Chapter Questions 95 7. The Programming Process 97 Setting Up 99 The Specification 100 Code Design 101 The Prototype 102 The Makefile 103 103 Testing 105 Debugging 106 Maintenance 108 Revisions 108 Electronic Archaeology 109 Mark Up the Program 109 Use the Debugger 110 Use the Text Editor as a Browser 110 Add Comments 110 Programming Exercises 113 II: Simple Programming 115 8: More Control Statements 117 for Statement 117 switch Statement 120 switch, break, and continue 125 Programming Exercises 127 Answers to Chapter Questions 128 Page vii 9: Variable Scope and Functions 129 Scope and Storage Class 129 Functions 133 Summary of Parameter Types 146 Structured Programming Basics 146 Recursion 148 148 Programming Exercises 149 Answers to Chapter Questions 149 10. The C++ Preprocessor 151 #define Statement 151 Conditional Compilation 157 #include Files 159 Parameterized Macros 160 Advanced Features 162 Summary 163 Programming Exercises 163 Answers to Chapter Questions 164 11: Bit Operations 167 Bit Operators 168 The AND Operator (&) 168 Bitwise OR ( | ) 171 The Bitwise Exclusive OR (^) 171 The Ones Complement Operator (NOT) (-) 171 The Left and Right Shift Operators (<<, >>) 172 Setting, Clearing, and Testing Bits 173 Bitmapped Graphics 176 Programming Exercises 181 Answers to Chapter Questions 182 III: Advanced Types and Classes 183 12: Advanced Types 185 Structures 185 185 Unions 188 typedef 190 Page ix enum Type 191 Bit Fields or Packed Structures 193 Arrays of Structures 195 Programming Exercises 196 13: Simple Classes 197 Stacks 197 Improved Stack 201 Using a Class 203 Introduction to Constructors and Destructors 205 Automatically Generated Member Functions 210 Shortcuts 211 Style 212 Programming Exercises 214 14: More on Classes 217 Friends 217 Constant Functions 219 Constant Members 220 Static Member Variables 222 Static Member Functions 223 The Meaning of static 224 Programming Exercises 225 225 15: Simple Pointers 227 Constant Pointers 232 Pointers and Printing 233 Pointers and Arrays 233 Splitting Strings 237 Pointers and Structures 240 Command-Line Arguments 241 Programming Exercises 245 Answers to Chapter Questions 245 Page x IV: Advanced Programming Concepts 249 16: File Input/Output 251 C++ File I/O 252 Conversion Routines 256 Binary and ASCII Files 260 The End-of-Line Puzzle 261 Binary I/O 262 Buffering Problems 263 Unbuffered I/O 264 Designing File Formats 268 C-Style I/O Routines 270 C-Style Conversion Routines 273 C-Style Binary I/O 276 Programming Exercises 278 278 Answers to Chapter Questions 278 17: Debugging and Optimization 281 Debugging 281 Serial Debugging 289 Divide and Conquer 290 Debug-Only Code 290 Debug Command-Line Switch 290 Going Through the Output 292 Interactive Debuggers 292 Debugging a Binary Search 296 Runtime Errors 307 The Confessional Method of Debugging 309 Optimization 309 The Power of Powers of 2 311 How to Optimize 314 Case Study: Inline Functions Versus Normal Functions 316 Case Study: Optimizing a Color-Rendering Algorithm 316 Programming Exercises 317 Answers to Chapter Questions 317 Page xi 18: Operator Overloading 319 Operator Functions 322 Operator Member Functions 330 Full Definition of the Complex Class 332 332 Programming Exercises 341 Answers to Chapter Questions 342 19 : Floating Point 343 Floating-Point Format 343 Floating Addition/Subtraction 344 Multiplication 345 Division 346 Overflow and Underflow 346 Roundoff Error 347 Accuracy 347 Minimizing Roundoff Error 348 Determining Accuracy 348 Precision and Speed 350 Power Series 351 Programming Exercises 352 20: Advanced Pointers 355 Pointers, Structures, and Classes 355 delete Operator 358 Linked List 359 Ordered Linked Lists 362 Double-linked List 365 Trees 368 Printing a Tree 373 The Rest of the Program 373 Data Structures for a Chess Program 377 Programming Exercises 378 378 Answers to Chapter Questions 379 21: Advanced Classes 381 Derived Classes 381 Virtual Functions 387 Page xii Virtual Classes 393 Function Hiding in Derived Classes 395 Constructors and Destructors in Derived Classes 396 Summary 398 Programming Exercises 399 Answers to Chapter Questions 399 V: Other Language Features 401 22: Exceptions 403 Stack Exceptions 405 Runtime Library Exceptions 410 Programming Exercises 410 23: Modular Programming 413 Modules 413 Public and Private 414 The extern Modifier 414 Headers 416 The Body of the Module 418 A Program to Use Infinite Arrays 418 The Makefile for Multiple Files 420 Using the Infinite Array 424 424 Dividing a Task into Modules 429 Module Division Example: Text Editor 430 Compiler Construction 431 Spread sheet 432 Module Design Guidelines 433 Programming Exercises 434 24: Templates 435 What Is a Template? 435 Templates: The Hard Way 435 Function Specialization 439 Class Templates 440 Class Specialization 442 Implementation Difficulties 442 Page xiii Summary 445 Programming Exercises 445 25: Portability Problems 447 Modularity 447 Word Size 448 Byte-Order Problem 448 Alignment Problem 449 NULL-Pointer Problem 450 Filename Problems 451 File Types 452 452 Summary 452 Answers to Chapter Questions 453 26: Putting It All Together 455 Requirements 455 Code Design 457 Coding 459 Functional Description 459 Testing 463 Revisions 464 A Final Warning 464 Program Files 464 Programming Exercises 483 27: From C to C++ 485 Overview 485 K&R-Style Functions 485 struct 486 malloc and free 486 Turning Structures into Classes 488 ssetjmp and longjmp 489 Summary 491 Programming Exercise 491 Page xiv 28. C++'s Dustier Corners 493 do/while 493 493 goto 493 The ?:Construct 495 The Comma Operator 495 Overloading the ( )Operator 495 Pointers to Members 496 Vampire Features 497 Answers to Chapter Questions 498 29: Programming Adages 499 General 499 Design 500 Declarations 500 switch Statement 500 Preprocessor 500 Style 501 Compiling 501 The Ten Commandments for C++ Programmers 501 Final Note 502 Answers to Chapter Questions 503 VI: Appendixes 505 A: ASCII Table 507 B: Ranges 511 C: Operator Precedence Rules 513 D: Computing sine Using a Power Series 515 Glossary 521 Index 543 Page xv Preface This book is devoted to practical C++ programming. It teaches you not only the mechanics of the language, but also style and debugging. The entire life cycle of a program is discussed, including conception, design, writing, debugging, release, documentation, maintenance, and revision. Style is emphasized. Creating a good program involves more than just typing code. It is an art in which writing and programming skills blend to form a masterpiece. A well-written program not only functions correctly, but also is simple and easy to understand. Comments allow programmers to include descriptive text in their programs. Clearly written, well-commented programs are highly prized. A program should be as simple as possible. Avoid the use of clever tricks. Cleverness and complexity can kill programs. This book stresses simple, practical rules. For example, the 15 operator-precedence rules in C++ can be simplified to 2: 1. Multiply and divide before you add and subtract. 2. Put parentheses around everything else. Consider two programs. One was written by a clever programmer, using all the tricks.
Recommended publications
  • Configuring UNIX-Specific Settings: Creating Symbolic Links : Snap
    Configuring UNIX-specific settings: Creating symbolic links Snap Creator Framework NetApp September 23, 2021 This PDF was generated from https://docs.netapp.com/us-en/snap-creator- framework/installation/task_creating_symbolic_links_for_domino_plug_in_on_linux_and_solaris_hosts.ht ml on September 23, 2021. Always check docs.netapp.com for the latest. Table of Contents Configuring UNIX-specific settings: Creating symbolic links . 1 Creating symbolic links for the Domino plug-in on Linux and Solaris hosts. 1 Creating symbolic links for the Domino plug-in on AIX hosts. 2 Configuring UNIX-specific settings: Creating symbolic links If you are going to install the Snap Creator Agent on a UNIX operating system (AIX, Linux, and Solaris), for the IBM Domino plug-in to work properly, three symbolic links (symlinks) must be created to link to Domino’s shared object files. Installation procedures vary slightly depending on the operating system. Refer to the appropriate procedure for your operating system. Domino does not support the HP-UX operating system. Creating symbolic links for the Domino plug-in on Linux and Solaris hosts You need to perform this procedure if you want to create symbolic links for the Domino plug-in on Linux and Solaris hosts. You should not copy and paste commands directly from this document; errors (such as incorrectly transferred characters caused by line breaks and hard returns) might result. Copy and paste the commands into a text editor, verify the commands, and then enter them in the CLI console. The paths provided in the following steps refer to the 32-bit systems; 64-bit systems must create simlinks to /usr/lib64 instead of /usr/lib.
    [Show full text]
  • Application Program Interface Guide
    APPLICATION PROGRAM INTERFACE GUIDE VWS-2001, VWS-2002 V WS-2001 V WS-2002 API GUIDE 24/7 TECHNICAL SUPPORT AT 1.877.877.2269 OR VISIT BLACKBOX.COM RemoteRemote Command Command Line Line Status Configure Status Client connected Enabled Monitor Client authorized Settings… Client disconnected Client authorized “C:\Program Files (x86)\Wall Control\wallctl.exe”- Active Server Telnet Command Lin — — — OK Cancel Apply Help NEED HELP? LEAVE THE TECH TO US LIVE 24/7 TABLE OF CONTENTS TECHNICAL SUPPORT 1.877.877.2269 1. INTRODUCTION ............................................................................................................................................................................. 3 1.1 API Programs ................................................................................................................................................................................................................3 1.2 Nomenclature ...............................................................................................................................................................................................................3 2. LAYOUTS ........................................................................................................................................................................................ 4 2.1 Example Usage ............................................................................................................................................................................................................4
    [Show full text]
  • Keyboard Shortcuts for Windows Computers
    AbilityNet Factsheet – May 2019 Keyboard Shortcuts for Windows computers This factsheet highlights some of the actions you can carry out quickly on your computer by using key combinations rather than using the mouse to navigate menus and options. These key combinations are referred to as shortcuts as they are often a much quicker way of carrying out tasks. They can also be particularly useful for repetitive actions. AbilityNet Factsheet: Keyboard Shortcuts Page 1 of 12 www.abilitynet.org.uk/factsheets May 2019 Contents 1. What are shortcuts ............................................................................................. 3 A note on Apple (Mac) computers ........................................................................... 3 Conventions ............................................................................................................. 3 Navigating Within Windows Using the Keyboard ..................................................... 4 Reference Chart ...................................................................................................... 7 Autocorrect as a shortcut ......................................................................................... 9 2. How can AbilityNet help? ................................................................................. 10 Free advice and home visits .................................................................................. 10 My Computer My Way ........................................................................................... 10 Workplace
    [Show full text]
  • J1939 Data Mapping Explained
    J1939 Data Mapping Explained Part No. BW2031 Revision: 1.05 May 18, 2018 Pyramid Solutions, Inc. 30200 Telegraph Road, Suite 440 Bingham Farms, MI 48025 www.pyramidsolutions.com | P: 248.549.1200 | F: 248.549.1400 © Pyramid Solutions 1 PUB-BW4031-001 Table of Contents Overview ......................................................................................................................... 2 J1939 Message Terminology ............................................................................................ 2 J1939 PGN Message Definitions ....................................................................................... 3 PGN and Parameter Documentation Examples ........................................................................ 3 J1939 Specification Example ........................................................................................................ 3 Parameter Table Example ............................................................................................................ 5 Determining the BridgeWay Data Table Layout ................................................................ 6 Data Table Layout for Modbus RTU and Modbus TCP (Big Endian) ........................................... 6 Data Table Layout for EtherNet/IP (Little Endian) .................................................................... 7 Configuring the BridgeWay I/O Mapping ......................................................................... 8 Configuration Attributes ........................................................................................................
    [Show full text]
  • Process and Memory Management Commands
    Process and Memory Management Commands This chapter describes the Cisco IOS XR software commands used to manage processes and memory. For more information about using the process and memory management commands to perform troubleshooting tasks, see Cisco ASR 9000 Series Aggregation Services Router Getting Started Guide. • clear context, on page 2 • dumpcore, on page 3 • exception coresize, on page 6 • exception filepath, on page 8 • exception pakmem, on page 12 • exception sparse, on page 14 • exception sprsize, on page 16 • follow, on page 18 • monitor threads, on page 25 • process, on page 29 • process core, on page 32 • process mandatory, on page 34 • show context, on page 36 • show dll, on page 39 • show exception, on page 42 • show memory, on page 44 • show memory compare, on page 47 • show memory heap, on page 50 • show processes, on page 54 Process and Memory Management Commands 1 Process and Memory Management Commands clear context clear context To clear core dump context information, use the clear context command in the appropriate mode. clear context location {node-id | all} Syntax Description location{node-id | all} (Optional) Clears core dump context information for a specified node. The node-id argument is expressed in the rack/slot/module notation. Use the all keyword to indicate all nodes. Command Default No default behavior or values Command Modes Administration EXEC EXEC mode Command History Release Modification Release 3.7.2 This command was introduced. Release 3.9.0 No modification. Usage Guidelines To use this command, you must be in a user group associated with a task group that includes appropriate task IDs.
    [Show full text]
  • B-Prolog User's Manual
    B-Prolog User's Manual (Version 8.1) Prolog, Agent, and Constraint Programming Neng-Fa Zhou Afany Software & CUNY & Kyutech Copyright c Afany Software, 1994-2014. Last updated February 23, 2014 Preface Welcome to B-Prolog, a versatile and efficient constraint logic programming (CLP) system. B-Prolog is being brought to you by Afany Software. The birth of CLP is a milestone in the history of programming languages. CLP combines two declarative programming paradigms: logic programming and constraint solving. The declarative nature has proven appealing in numerous ap- plications, including computer-aided design and verification, databases, software engineering, optimization, configuration, graphical user interfaces, and language processing. It greatly enhances the productivity of software development and soft- ware maintainability. In addition, because of the availability of efficient constraint- solving, memory management, and compilation techniques, CLP programs can be more efficient than their counterparts that are written in procedural languages. B-Prolog is a Prolog system with extensions for programming concurrency, constraints, and interactive graphics. The system is based on a significantly refined WAM [1], called TOAM Jr. [19] (a successor of TOAM [16]), which facilitates software emulation. In addition to a TOAM emulator with a garbage collector that is written in C, the system consists of a compiler and an interpreter that are written in Prolog, and a library of built-in predicates that are written in C and in Prolog. B-Prolog does not only accept standard-form Prolog programs, but also accepts matching clauses, in which the determinacy and input/output unifications are explicitly denoted. Matching clauses are compiled into more compact and faster code than standard-form clauses.
    [Show full text]
  • How to Dump and Load
    How To Dump And Load Sometimes it becomes necessary to reorganize the data in your database (for example, to move data from type i data areas to type ii data areas so you can take advantage of the latest features)or to move parts of it from one database to another. The process for doping this can be quite simple or quite complex, depending on your environment, the size of your database, what features you are using, and how much time you have. Will you remember to recreate the accounts for SQL users? To resotre theie privileges? Will your loaded database be using the proper character set and collations? What about JTA? Replication? etc. We will show you how to do all the other things you need to do in addition to just dumping and loading the data in your tables. 1 How To Dump and Load gus bjorklund head groundskeeper, parmington foundation 2 What do we mean by dumping and loading? • Extract all the data from a database (or storage area) • Insert the data into a new database (or storage area) • Could be entire database or part 3 Why do we dump and load? 4 Why do we dump & load? • To migrate between platforms • To upgrade OpenEdge to new version • To repair corruption • To “improve performance” • To change storage area configuration • To defragment or improve “scatter” • To fix a “long rm chain” problem • Because it is October 5 Ways to dump and load • Dictionary • 4GL BUFFER-COPY • Binary • Replication triggers (or CDC) • Table partitioning / 4GL • Incremental by storage area 6 Binary Dump & Load • binary dump files – not "human readable"
    [Show full text]
  • Advanced Software Engineering with C++ Templates Lecture 4: Separate Compilation and Templates III
    Advanced Software Engineering with C++ Templates Lecture 4: Separate Compilation and Templates III Thomas Gschwind <thgatzurichdotibmdotcom> Agenda . Separate Compilation • Introduction (C++ versus Java) • Variables • Routines (Functions & Operators) • Types (Structures, Classes) • Makefiles . Templates III • Design and Implementation (C++ versus Java versus C#) • “Dynamic” Static Algorithm Selection • Binders Th. Gschwind. Fortgeschrittene Programmierung in C++. 2 Separate Compilation . Why? • Having only one source file is unrealistic • Break the code up into its logical structure • Reduction of compile time - Only changed parts need to be recompiled . How? • Use multiple source files • Need to know what information about functions and variables “used” from other files Th. Gschwind. Fortgeschrittene Programmierung in C++. 3 Separate Compilation in Java . Each Java file is compiled into a class file . If a Java class invokes a method of another class, the compiler consults that other class file to • Determine whether the class provides the requested method • Determine whether a class file implements a given interface • etc. • Hence, the .class file contains the entire interface . That’s why in Java, the compiler needs the class path . Finally, all class files are loaded by the Java Virtual Machine (and “linked”) . Java source code can be relatively well reconstructed from .class file (see Java Decompiler: jd, jad) Th. Gschwind. Fortgeschrittene Programmierung in C++. 4 Some Java Trivia . Let us write Hello World in Java . In order to simplify the reconfiguration (e.g., translation) • Put all the constants into one Java file • Put the complex application code into another public class Const { public static final String msg="Hello World!"; } public class Cool { public static void main(String[] args) { System.out.println(Const.msg); } } Th.
    [Show full text]
  • 13-DUALOSS-MV Commercial Grade In-Wall Occupancy/Vacancy Sensor
    13-DUALOSS-MV Commercial Grade In-Wall Occupancy/Vacancy Sensor APPLICATIONS This Multi-Technology Wall Switch Sensor combine advanced passive infrared (PIR) and ultrasonic technologies into one unit. The combined technologies helps eliminate false triggering even in difficult applications. Selectable operating modes allow the sensor to turn a load on, and hold it on as long as either or both technologies detect occupancy . After no movement is detected for the selected time delay, the lights switch off. A "walk-through" mode can turn lights off after only 3 minutes, if no activity is detected after 30 seconds following an occupancy detection. This sensor also contains a light level sensor. If adequate daylight is present, the sensor holds the load OFF until light levels drop, even if the area is occupied. MODEL #: 13-DUALOSS-MV FEATURES • Integrated PIR and Ultrasonic sensor technology to detect very fine COVERAGE AREA motion and provide accurate motion sensing Top View • Allows to choose triggering when both technologies detect motion or when only PIR detects motion 20' • Less false trigger, fast ON/OFF; commercial grade sensor for closet, garage, hotels, meeting room, work places 10' • Adjustable timeout from 15 seconds to 30 minutes; Walk-Through mode: 3 minutes if no activity after first 30 seconds SPECIFICATIONS 10' • Voltage: 120/277VAC, 50/60Hz • Incandescent: 800W-120VAC, 50/60Hz • Fluorescent: 800VA-120VAC, 1600VA-277VAC, 50/60Hz 20' • Resistive: 800W-120VAC, 50/60Hz • Motor: 1/4 HP-120VAC, 50/60Hz • Adjustment Time Delay: 5 Sec to 30 Mins 5' • Walk-Through Mode: 3-minutes if no activity after 30 sec.
    [Show full text]
  • The NTFS File System
    The NTFS File System OVERVIEW: This lab is part of a series of lab exercises intended to support courseware for Forensics training. The development of this document is funded by the Department of Labor (DOL) Trade Adjustment Assistance Community College and Career Training (TAACCCT) Grant No. TC-22525-11-60-A-48. In this lab, students will enumerate hosts on the network using various tools. This lab includes the following tasks: 1 – Examining the NTFS File System 2 – Using a HEX Editor to explore an NTFS Partition 3 – Verifying and viewing the image details 4 – Analyzing an NTFS Partition With Autopsy Key TermDescription The acronym NTFS stands for New Technology File System. The NTFS File System was originally introduced with the Windows NT. NTFS is a journaling file system which means it keeps a log of changes being written to the disk. If a computer is shutdown improperly, it will have a better NTFS chance of recovery if it has a journaling file system. Files and folder access can be restricted with the security feature of NTFS. Starting with Windows 2000, Microsoft included the Encrypted File System, or EFS, as an NTFS feature. EFS allows users to encrypt files to protect against unauthorized access. A Feature of the NTFS File system that allows you to encrypt files and folders. The feature EFS became available on the NTFS File system starting with Windows 2000, and is still available today on Windows 10 and Server 2016. An Alternate Data Stream, or ADS, is a feature of the NTFS file system that allowed compatibility ADS with older versions of the Mac OS.
    [Show full text]
  • Cobol Vs Standards and Conventions
    Number: 11.10 COBOL VS STANDARDS AND CONVENTIONS July 2005 Number: 11.10 Effective: 07/01/05 TABLE OF CONTENTS 1 INTRODUCTION .................................................................................................................................................. 1 1.1 PURPOSE .................................................................................................................................................. 1 1.2 SCOPE ...................................................................................................................................................... 1 1.3 APPLICABILITY ........................................................................................................................................... 2 1.4 MAINFRAME COMPUTER PROCESSING ....................................................................................................... 2 1.5 MAINFRAME PRODUCTION JOB MANAGEMENT ............................................................................................ 2 1.6 COMMENTS AND SUGGESTIONS ................................................................................................................. 3 2 COBOL DESIGN STANDARDS .......................................................................................................................... 3 2.1 IDENTIFICATION DIVISION .................................................................................................................. 4 2.1.1 PROGRAM-ID ..........................................................................................................................
    [Show full text]
  • Mac Keyboard Shortcuts Cut, Copy, Paste, and Other Common Shortcuts
    Mac keyboard shortcuts By pressing a combination of keys, you can do things that normally need a mouse, trackpad, or other input device. To use a keyboard shortcut, hold down one or more modifier keys while pressing the last key of the shortcut. For example, to use the shortcut Command-C (copy), hold down Command, press C, then release both keys. Mac menus and keyboards often use symbols for certain keys, including the modifier keys: Command ⌘ Option ⌥ Caps Lock ⇪ Shift ⇧ Control ⌃ Fn If you're using a keyboard made for Windows PCs, use the Alt key instead of Option, and the Windows logo key instead of Command. Some Mac keyboards and shortcuts use special keys in the top row, which include icons for volume, display brightness, and other functions. Press the icon key to perform that function, or combine it with the Fn key to use it as an F1, F2, F3, or other standard function key. To learn more shortcuts, check the menus of the app you're using. Every app can have its own shortcuts, and shortcuts that work in one app may not work in another. Cut, copy, paste, and other common shortcuts Shortcut Description Command-X Cut: Remove the selected item and copy it to the Clipboard. Command-C Copy the selected item to the Clipboard. This also works for files in the Finder. Command-V Paste the contents of the Clipboard into the current document or app. This also works for files in the Finder. Command-Z Undo the previous command. You can then press Command-Shift-Z to Redo, reversing the undo command.
    [Show full text]