Using Visual C++ and Pelles C

Similar documents
Introduction to the use of the environment of Microsoft Visual Studio 2008

Appendix K Introduction to Microsoft Visual C++ 6.0

Microsoft Visual Studio 2010 Instructions For C Programs

DEPLOYING A VISUAL BASIC.NET APPLICATION

Creating a Simple Visual C++ Program

Generating Visual Studio Project Files

Programming with the Dev C++ IDE

Appendix M: Introduction to Microsoft Visual C Express Edition

Virtual Office Remote Installation Guide

Using Microsoft Visual Studio API Reference

Installing Globodox Web Client on Windows 7 (64 bit)

Configuring Thunderbird for Flinders Mail at home.

MS Visual C++ Introduction. Quick Introduction. A1 Visual C++

Creating Database Tables in Microsoft SQL Server

Visual Studio 2008 Express Editions

Lab 2 - CMPS 1043, Computer Science I Introduction to File Input/Output (I/O) Projects and Solutions (C++)

How to Compile, Link, and Execute C or C++ Codes Using Microsoft Visual C++

USER GUIDE FOR DIGITAL CERTIFICATE

Developing, Deploying, and Debugging Applications on Windows Embedded Standard 7

3 IDE (Integrated Development Environment)

Visual C Tutorial

Installing Java 5.0 and Eclipse on Mac OS X

MANAGING OUTLOOK PERSONAL DATA FILES

SQL Server 2005: Report Builder

Creating and Issuing the Workstation Authentication Certificate Template on the Certification Authority

Aspera Connect User Guide

Eclipse installation, configuration and operation

Configuring browser settings (Internet Explorer and Google Chrome) for Bug Club via a Group Policy

Windows Server Update Services 3.0 SP2 Step By Step Guide

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

Customize tab; click the Accounts category; drag the satellite dish icon to your toolbar.

Install the Production Treasury Root Certificate (Vista / Win 7)

How to test and debug an ASP.NET application

OUTLOOK ANYWHERE CONNECTION GUIDE FOR USERS OF OUTLOOK 2010

OUTLOOK WEB APP (OWA): MAIL

owncloud Configuration and Usage Guide

Working with SQL Server Integration Services

Mitigation Planning Portal MPP Reporting System

Tutorial: Packaging your server build

INSTALLATION INSTRUCTIONS FOR UKSSOGATEWAY

CROWNPEAK C# API SYSTEM CONFIGURATION GUIDE VERSION 3.0.1

Junk Settings. Options

Start A New Project with Keil Microcontroller Development Kit Version 5 and Freescale FRDM-KL25Z

FTP Server Configuration

CS106B Handout #5P Winter January 14, 2008

Hypercosm. Studio.

Microsoft Access Database

Chapter 1: Getting Started

How to configure the DBxtra Report Web Service on IIS (Internet Information Server)

TSM for Windows Installation Instructions: Download the latest TSM Client Using the following link:

From Data Modeling to Data Dictionary Written Date : January 20, 2014

For example, you might want to create a folder to collect together all s relating to a particular project or subject.

PigCHAMP Knowledge Software. Enterprise Edition Installation Guide

Macintosh: Microsoft Outlook Web Access

Online Backup and Recovery Manager Setup for Microsoft Windows.

Creating OpenGL applications that use GLUT

HOW TO BURN A CD/DVD IN WINDOWS XP. Data Projects

Data Tool Platform SQL Development Tools

How to share media files through Windows Media Player 11

1. The First Visual C++ Program

Installation...2 Installation of Athena Visual Studio...2 Authorization...3 Authorization for Corporate License Users...3 Authorization for

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

1.1 Installing Protégé You can follow the steps below to download and install Protégé from the source.

Hands-On Lab. Web Development in Visual Studio Lab version: Last updated: 12/10/2010. Page 1

Composite.Community.Newsletter - User Guide

Librarian. Integrating Secure Workflow and Revision Control into Your Production Environment WHITE PAPER

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

EventTracker: Support to Non English Systems

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

1 EDI Source EDI/HQ. Troubleshooting Licensing Issues. for Microsoft Windows 7 and Microsoft Windows 2008 Server

Backing up Microsoft Outlook For the PC Using MS Outlook 2000 Keith Roberts

Fairfield University Using Xythos for File Sharing

Installing the ASP.NET VETtrak APIs onto IIS 5 or 6

TIPS & TRICKS JOHN STEVENSON

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

SSL Intercept Mode. Certificate Installation Guide. Revision Warning and Disclaimer

Configuring a Custom Load Evaluator Use the XenApp1 virtual machine, logged on as the XenApp\administrator user for this task.

Compiler Setup and DirectX/OpenGL Setup

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

CISCO VPN CLIENT INSTALL AND UPDATE INSTRUCTIONS

Introduction to Eclipse

KeePass Getting Started on Windows

VirtualXP Users Guide

Web Application Development

MTA Course: Windows Operating System Fundamentals Topic: Understand backup and recovery methods File name: 10753_WindowsOS_SA_6.

Upgrading MySQL from 32-bit to 64-bit

Installing the Dark GDK with Visual Studio 2008

Releasing blocked in Data Security

Appendix B Lab Setup Guide

Installing Globodox Web Client on Windows Server 2012

Changing Passwords in Cisco Unity 8.x

You may have been given a download link on your trial software . Use this link to download the software.

Installing LearningBay Enterprise Part 2

Notepad++ The COMPSCI 101 Text Editor for Windows. What is a text editor? Install Python 3

Using NetBeans to Compile and Run Java Programs

Downloading Driver Files

Ajax Chat Integration for Joomla 1.5 native

Transcription:

Using Visual C++ and Pelles C -IDE & Compilerswww.tenouk.com, 1/48

(2008) In this session we will learn how to use VC++ to build a sample C program. We assume VC++ (Visual Studio) was successfully installed. Step: Launch VC++. Step: Click File menu > New sub-menu > select Project sub-menu. www.tenouk.com, 2/48

Step: select Win32 for the Project types > select Win32 Console Application for Templates. Step: Enter the project Name > click OK button. We just keep other settings to default. www.tenouk.com, 3/48

Step: select Application Settings (or Next > button). www.tenouk.com, 4/48

Step: select Empty project for Additional options > click Finish button. Other settings set to default because we just want an empty Win32 console mode application. www.tenouk.com, 5/48

Now, on the left pane we have one solution and in it we have one project that we just created. First project creation will create the first solution automatically. At this stage we just having an empty project. www.tenouk.com, 6/48

Step: select the project root folder > right-click mouse > select Add sub-menu > select New Item sub-menu. We are going to add C a source file to the project. www.tenouk.com, 7/48

Step: select Code for Categories > select C++ File (.cpp) for Templates. Step: put the source file name with.c extension for the Name. Step: change the Location if needed > click Add button. If we do not put the.c extension, the file will be defaulted to.cpp which is C++ source file. For C source code portability, we need to put.c manually in VC++. www.tenouk.com, 8/48

Now we have an empty C source file on the right pane. If the file is not opened, just double-click the file link on the left pane. www.tenouk.com, 9/48

#include <stdio.h> int main(void) { int i, p; float x; char name[50]; Using VC++ Step: Copy and paste the following C source code to the source file. printf("key-in an integer, float and a string\n"); p = scanf("%d%f%s", &i, &x, name); printf("p = %i\n", p); return 0; } Code sample in text 1 www.tenouk.com, 10/48

Now the C source file has source code in it. We are ready to build (compile and link) the project. www.tenouk.com, 11/48

Step: select Build menu > select Compile sub-menu. www.tenouk.com, 12/48

Optionally, we can directly build the solution (Build Solution submenu) or we can just build the project (Build exercise_1 in this case). Both steps will compile and link the needed files. However in this case we only have 1 solution and in it we only have 1 project and in it we only have 1 C source file! There can be more than 1 solution and in 1 solution there can be more projects and in every projects there can be 100s or 1000s files!!! www.tenouk.com, 13/48

The output of the compiling process can be seen in the Output window. You can invoke the Output windows by clicking View menu and selecting Output sub-menu (or Alt + 2) VS 2008. We have to make sure there is no error (optionally and/or warning) else the project/program cannot be run. www.tenouk.com, 14/48

Provided there is no error during the building, we are ready to run the program. Step: click Debug menu > select Start Without Debugging sub-menu. We are not going to debug this program but just to run it. So we choose Start Without Debugging instead of Start Debugging. www.tenouk.com, 15/48

Now the console windows launched, ready to accept our input. Step: For the purpose of learning, key-in "31 52.42E-1 Tiger" and press Enter key. Of course without the double quotes. A space (whitespace) terminate C statement and in this case terminate an input. www.tenouk.com, 16/48

What this program does is: Prompt user for inputs, assigns to p the value 3, to i the value 31, to x the value 5.242, and name contains the string "Tiger" and print p s value. www.tenouk.com, 17/48

Step: Replace the previous C source code with the following. Step: re-build and re-run the project key-in 31 52.42E-1 Tiger and press Enter key The details can be depicted as shown below. #include <stdio.h> int main(void) { int i, p; float x; char name[50]; printf("key-in an integer, float and a string\n"); p = scanf("%d%f%s", &i, &x, name); printf("p = %i, i = %i, x = %f, name = %s\n", p, i, x, name); return 0; } assigns to p the value 3, to i the value 31, to x the value 5.242, and name contains the string "Tiger". Code sample in text 2 www.tenouk.com, 18/48

The following is a sample output. assigns to p the value 3, to i the value 31, to x the value 5.242, and name contains the string "Tiger". www.tenouk.com, 19/48

#include <stdio.h> Using VC++ Step: next, try re-run the program and key-in another different inputs. int main(void) { int i, p; float x; char name[50]; 32 52.42E-1 Tiger 56789 0123 56a72 printf("key-in an integer, float and a string\n"); p = scanf("%d%f%s", &i, &x, name); printf("p = %i, i = %i, x = %f, name = %s\n", p, i, x, name); scanf("%2d%f%*d %[0123456789]", &i, &x, name); printf("i = %i, x = %f, name = %s\n", i, x, name); return 0; } Code sample in text 3 Assigns 56 to i, 789.0 to x, skips 0123, and places the string "56\0" in name www.tenouk.com, 20/48

The following is a sample output. For the second input: Assigns 56 to i, 789.0 to x, skips 0123, and places the string "56\0" in name www.tenouk.com, 21/48

In the following steps, we are going to use the default extension.cpp and then 'force' compiler to compile the program as C code. Step: Close the previous Solution: select File menu > select Close Solution. Step: Create new empty Win32 console mode application project as done previously. www.tenouk.com, 22/48

Step: click Application Settings or click Next > button. www.tenouk.com, 23/48

Step: select Empty project tick box > click Finish button. Left other settings as default. www.tenouk.com, 24/48

Step: add the source file. Select the project root folder > right-click mouse > select Add sub-menu > select New Item sub-menu. www.tenouk.com, 25/48

Step: However in this step we are not adding the.c extension (VC++ will add.cpp by default) www.tenouk.com, 26/48

#include <stdio.h> Using VC++ Step: Copy and paste the following C source code. int main(void) { printf("%%#x:\t%#x\n", 141); printf("%%g:\t%g\n", 5.1234567); printf("%%07d:\t%07d\n", 123); printf("%%+d:\t%+d\n", 456); printf("%%-7d:\t%-7d,%%-5d:\t%-5d,\n", 33, 44); printf("%%7s:\t%7s\n", "123456"); printf("%%s:\t%s\n", "my name"); printf("%%4f:\t%4f\n", 41.1234); printf("%%8.5f:\t%8.5f\n", 1323.2346); printf("%%.3f:\t%.3f\n", 15.4321); printf("%%hd:\t%hd\n", 7); printf("%%ld:\t%ld\n", 9); printf("%%lg:\t%lg\n", 45.23456123); Code sample in text 4 return 0; } www.tenouk.com, 27/48

In order to force this C source code built as C code we need to tell compiler to do so for this project. Step: select Project menu > select your_project_name Properties sub-menu. www.tenouk.com, 28/48

Step: expand the Configuration Properties folder > expand the C/C++ sub-folder > select Advanced link from the left pane. Step: on the right pane, for Compile As option, select Compile as C Code (/TC) > click OK button. www.tenouk.com, 29/48

Step: Build the program as done previously. Make sure there is no error. www.tenouk.com, 30/48

Step: run the program as done previously. www.tenouk.com, 31/48

The following shows a sample output. www.tenouk.com, 32/48

Compared to the previous example, the source file extension is.cpp instead of.c. However, through the project settings we tell VC++ to build this C source code as C. www.tenouk.com, 33/48

USING PELLES C www.tenouk.com, 34/48

Using Pelles C Step: download Pelles C installation at: Pelles C Don t forget to select your appropriate platform. Double click the executable (.exe) to install Pelles C. Launch Pelles C IDE. www.tenouk.com, 35/48

Using Pelles C www.tenouk.com, 36/48

Using Pelles C Step: select Start a new project link. www.tenouk.com, 37/48

Using Pelles C Step: select Win32 Console program (EXE) project type > put the project name > click OK button. www.tenouk.com, 38/48

Using Pelles C Step: select the project root folder > right-click mouse > select Add files to project menu. www.tenouk.com, 39/48

Using Pelles C Step: put the C source file name with.c extension > click Open button. www.tenouk.com, 40/48

Using Pelles C Now, the source file is opened in the editor else you can double-click the source file name. www.tenouk.com, 41/48

#include <stdio.h> int main(void) { int i, p; float x; char name[50]; Using Pelles C Step: copy and paste the following C source code into the source file. printf("key-in an integer, float and a string\n"); p = scanf("%d%f%s", &i, &x, name); printf("p = %i\n", p); return 0; } Code sample in text 5 www.tenouk.com, 42/48

Using Pelles C www.tenouk.com, 43/48

Using Pelles C Step: invoke Project menu > select Build your_project_name.exe sub-menu. We are going to build (compile and link) this project. www.tenouk.com, 44/48

Using Pelles C The output can be viewed in the Project window. www.tenouk.com, 45/48

Using Pelles C Step: invoke the Project menu > select Execute your_project_name.exe sub-menu. We are going to run this project. www.tenouk.com, 46/48

Using Pelles C Step: key-in a sample input: 51 5.3427 lion and press Enter key. The following is a sample output. www.tenouk.com, 47/48

End. Thank you www.tenouk.com, 48/48