Visual C++ Tutorial. For Introduction to Programming with C++ By Y. Daniel Liang

Similar documents
CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2005

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2003

TREX Set-Up Guide: Creating a TREX Executable File for Windows

EECE.2160: ECE Application Programming Spring 2018 Programming Assignment #1: A Simple C Program Due Monday, 1/29/18, 11:59:59 PM

WRITING CONSOLE APPLICATIONS IN C

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010

Eclipse Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Opening Microsoft Visual Studio. On Microsoft Windows Vista and XP to open the visual studio do the following:

If your machine is not connected to any network, you can configure the Microsoft Loopback Adapter to simulate a network connection.

Installing and getting started with Visual Studio for C programming in Windows.

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

Supplement H.1: JBuilder X Tutorial. For Introduction to Java Programming, 5E By Y. Daniel Liang

Supplement II.B(1): JBuilder X Tutorial. For Introduction to Java Programming By Y. Daniel Liang

Welcome Application. Introduction to C++ Programming (Solutions) 2004 by Deitel & Associates, Inc. All Rights Reserved.

Compiling MapleSim C-Code in Visual C Express

MS Visual Studio.Net 2008 Tutorial

As CCS starts up, a splash screen similar to one shown below will appear.

Lab 4: Introduction to Programming

As CCS starts up, a splash screen similar to one shown below will appear.

NetBeans Tutorial. For Introduction to Java Programming By Y. Daniel Liang. This tutorial applies to NetBeans 6, 7, or a higher version.

Appendix M: Introduction to Microsoft Visual C Express Edition

Tutorial : creating a Max/MSP external project for Windows using Visual Studio

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

ECE 103 In-Class Exercise L1 Guide

Tutorial - Exporting Models to Simulink

PART 1: Getting Started

Module 3: Working with C/C++

APPENDIX A. CODE COMPOSER STUDIO (CCS) v5: A BRIEF TUTORIAL FOR THE DSK6713

Eclipse CDT Tutorial. Eclipse CDT Homepage: Tutorial written by: James D Aniello

Getting Started with Visual Studio

clicking on the on the New

IMPLEMENTING SCL PROGRAMS. Using Codeblocks

Setting up a Project and Debugging with Visual Studio

How to debug Wcem.dll with.net Studio

Code Composer Studio Operation Manual

RTX MiniTutorial DEBUGGING APPLICATIONS USING VISUAL STUDIO

Tutorial on Simulation using Aldec Active-HDL Ver 1.0

To install the Texas Instruments CCS Compiler, follow these steps: 1. Go to the TI Wiki page (

Check the Desktop development with C++ in the install options. You may want to take 15 minutes to try the Hello World C++ tutorial:

Lab 5: Reporting with RPE

AN 834: Developing for the Intel HLS Compiler with an IDE

UNic Eclipse Mini Tutorial (Updated 06/09/2012) Prepared by Harald Gjermundrod

Developing Intelligent Apps

F28069 ControlCard Lab1

Application Note 112

Using Code Composer Studio IDE with MSP432

Section 2: Getting Started with a FPU Demo Project using EK-LM4F232

Supplement: Visual C++ Debugging

Configuring Visual Studio 2017 with SFML Game Engine

Using Eclipse. Computational Thinking and Engineering for pre-college! Using Eclipse. Must READ:

C++ - OpenGL - Setting up Visual Studio

Migration from HEW to e 2 studio Development Tools > IDEs

Using OpenGL & GLUT in Visual Studio.NET 2003

Debugging in AVR32 Studio

CANape ASAM-MCD3 Interface Version Application Note AN-AMC-1-103

CS 210 November 3, 2016 Notes on Separately Compile Programs

This manual will explain how to do a mail merge in Cordell Connect, using the following Windows programs:

Using Code Templates to enhance software consistency and quality

Lab 1: First Steps in C++ - Eclipse

Laboratory Assignment #3 Eclipse CDT

EDEM Dynamics Coupling Quick Start Guide

Deitel Dive-Into Series: Dive-Into Cygwin and GNU C++

Tutorial 1: Simple Parameterized Mapping

This tutorial is designed for software programmers who would like to learn the basics of ASP.NET Core from scratch.

A Tutorial for ECE 175

TOP SERVER V5 CLIENT CONNECTIVITY ROCKWELL FACTORYTALK VIEW STUDIO. Table of Contents

Building an Embedded Processor System on a Xilinx Zync FPGA (Profiling): A Tutorial

'phred dist acd.tar.z'

1) Use either Chrome of Firefox to access the VMware vsphere web Client. FireFox

Optimal Trace MS Project Integration

Introduction to C/C++ Programming

You have a PC with a USB interface, running Microsoft Windows XP (SP2 or greater) or Vista You have the Workshop Installation Software Flash Drive

Table of Contents CONSOLE BASED APPLICATION 2

MAIL MERGE DIRECTORY USE THE MAIL MERGE WIZARD

Script Host 2.0 Developer's Guide

JEE2600 INTRODUCTION TO DIGITAL LOGIC AND COMPUTER DESIGN. ModelSim Tutorial. Prepared by: Phil Beck 9/8/2008. Voter Function

1) Use either Chrome of Firefox to access the VMware vsphere web Client. FireFox

WEBppliance for Windows User Administrator's Help

FTP UPLOADS/DOWNLOADS

Desktop Studio: Report Templates. Version: 7.3

COINS Ti Call Management System Standard Installation Instructions for Citrix Users

Tools Basics. Getting Started with Renesas Development Tools R8C/3LX Family

ECE 480 Application Note. By: Jacob Hersha 4/3/15. Creating a Sequence of Media with Visual Studio

Spartan-6 LX9 MicroBoard Embedded Tutorial. Tutorial 1 Creating an AXI-based Embedded System

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

CIS 231 Windows 7 Install Lab #2

QUICKSTART CODE COMPOSER STUDIO Stellaris Development and Evaluation Kits for Code Composer Studio

Lab 0 Introduction to the MSP430F5529 Launchpad-based Lab Board and Code Composer Studio

Newforma Contact Directory Quick Reference Guide

Eclipse Environment Setup

CLIB. How to integrate the CLIB. into. Borland C and. Paradigm C/C++ Beck IPC Edition

Using the Dev C++ Compiler to Create a Program

Figure 1. Simplicity Studio

Desktop Studio: Report Templates

Supplement B. Creating, Compiling and Running Java Programs from the Command Window

Building an Application to Dynamically Execute Partner Process Flows

DEVELOPING OOSIML SIMULATION MODELS. Using Codeblocks

Citrix Connector 7.5 for Configuration Manager. Using Provisioning Services with Citrix Connector 7.5 for Configuration Manager

Activating AspxCodeGen 4.0

User Guide. Introduction. Requirements. Installing and Configuring. C Interface for NI myrio

Transcription:

1 Introduction Visual C++ Tutorial For Introduction to Programming with C++ By Y. Daniel Liang Visual C++ is a component of Microsoft Visual Studio 2012 for developing C++ programs. A free version named Visual Studio Express can be downloaded from Supplement II.A. This section introduces how to create a project, create a program, compile and run the program in Visual C++. The screen shots are from VC 2012. It is same for VC 2017. 2 Getting Started with Visual C++ Visual C++ is easy to install. If you need help with installation, please refer to Supplement II.A on the Companion Website. Suppose you have installed Visual C++ 2012 Express Edition. You can launch Visual C++ from the Windows Start button by choosing VS Express for Desktop. The Visual C++ 2012 Express user interface appears, as shown in Figure 1. Figure 1 1

The Visual C++ user interface is a single window that performs editing, compiling, debugging, and running programs. 3 Creating a Project To create C++ programs in Visual C++, you have to first create a project. A project is like a holder that ties all the files together. Here are the steps to create a project: 1. Choose File, New, Project to display the New Project window, as shown in Figure 2. 2. Choose C++ under the Template and select Win32 Console Application in the middle column. Type bookexample in the Name field and c:\smith in the Location field. Click OK to display the Win32 Application Wizard window, as shown in Figure 3. 3. Click Next to display the application settings window, as shown in Figure 4. 4. Select Console application in the Application type section and check Empty project in the Additional options section. Click Finish to create a project. You will see the project named bookexample in the Solution Explorer, as shown in Figure 5. Figure 2 You need to create a project before creating programs. 2

Figure 3 Win32 Application Wizard creates a project for Win32 applications. Choose Empty Figure 4 Win32 Application Settings window lets you set the application type. 3

Solution Explorer shows Figure 5 A project is created for C++ console applications. 4 Creating a C++ Program After you create a project, you can create programs in it. Here are the steps to create a C++ program for Listing 1.1: 1. Right-click the bookexample project in the Solution Explorer to display a context menu. Choose Add, Add New Item from the context menu of the bookexample project (see Figure 6) to display the Add New Item window, as shown in Figure 7. 2. Choose Code under Visual C++ on the left column and C++ File (.cpp) in the middle column. Enter Welcome in the Name field and c:\smith\bookexample\bookexample in the Location field. Click Add to create the file, as shown in Figure 8. 3. Enter the code for Welcome.cpp exactly from Listing 1.1, as shown in Figure 9. 4

Figure 6 You can open the Add New Item window from the project s context menu. Figure 7 You can specify the file type, name, and location to create a file. 5

Figure 8 Welcome.cpp is created in the project. Figure 9 The source code for Welcome.cpp is entered. 5 Compiling a C++ Program 6

After you create a program, you can compile it. You may do so by choosing Build, Compile, or press Ctrl+F7, or choose Compile in the context menu for Welcome.cpp, as shown in Figure 10. Figure 10 Choose the Compile command to compile the program. 6 Running a C++ Program To run the program, press Ctrl+F5. You will see the output displayed in a DOS window, as shown in Figure 11. Figure 11 The output is displayed in a DOS window. NOTE: <Side Remark: compile and run> The Run command invokes the Compile command if the program is not compiled or was modified after the last compilation. NOTE: <Side Remark: one main function> 7

Each project can have only one file that contains a main function. If you need to create another file with a main function, you have two options: Remove the current file that contains a main function from the project by choosing Remove from the context menu of the program, as shown in Figure 12. (Note that you can add an existing file to the project by choosing File, Add Existing Item.) Create a new project for the new program. Figure 12 You can remove a file from a project. ***END NOTE 7 Including Header File from Different Directories In Chapter 9, you will learn header files. You need to add the header files in the Header Files node under the project node. If a header file is in a directory that is different from the program directory, you need to add the directory in the project properties. For example, suppose Test.cpp needs to include Circle.h and Circle.h is in c:\teacher. Follow the steps below to add c:\teacher in the project property dialog box: 1. Right-click on Test.cpp in the Solution explorer to display a context dialog box, as shown in Figure 13. 8

2. Choose Properties to display Project Properties dialog box, as shown in Figure 14. 3. Choose General under C/C++ on the left column. Enter c:\teacher in the Additional Include Directories field. Figure 13 You can customize project properties in VC++. 9

Figure 14 C:\teacher is added in the path. 10