Using Visual C++ and Pelles C

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
1 CSCI N305 C Language Programming Welcome to CSCI N305! Compiling Your First Program Using Microsoft Visual Studio 2008.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
The Windows Registry Adapted from
C Pre-Course Workshop Terence Lee QT406 -> PQ607
CS 1400 Using Microsoft Visual Studio 2005 if you don’t have the appropriate appendix.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
Create A Visual Studio Template
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2005 CHAPTER 12 Cell Phone Applications and Web Services.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
SQL Maestro Hello World IQ Associates. Contents Initial setup Hello World.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - HelloWorld Application: Introduction to.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Working with Unmanaged Code.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 22 Macros.
CS Tutorial 1 Getting Started with Visual Studio 2012 (Visual Studio 2010 are no longer available on MSDNAA, please choose Visual Studio 2012 which.
Intro to C++. Getting Started with Microsoft Visual Studios Open Microsoft Visual Studios 2010 Click on file Click on New Project Choose Visual C++ on.
Setting up Eclipse Computer Organization I 1 August 2009 ©2009 McQuain Getting Eclipse for C/C++ Development Go to and click on Download.
Lecture Set 2 Part B – Configuring Visual Studio; Configuration Options and The Help System (scan quickly for future reference)
A1 Visual C++.NET Intro Programming in C++ Computer Science Dept Va Tech August, 2002 © Barnette ND & McQuain WD 1 Quick Introduction The following.
Lecture Set 1 Part C: Understanding Visual Studio and.NET – Applications, Solutions, Projects (no longer used – embedded in Lecture Set 2A)
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
Creating a Project with C++ Builder
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Lecture 6: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
Computer Science I How to Configure Visual Studio.NET 2003 for C++ Colin Goble.
Our Environment We will exercise on Microsoft Visual C++ v.6 We will exercise on Microsoft Visual C++ v.6 because that is what we have in the univ. because.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Active-HDL Interfaces Debugging C Code Course 10.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files.
Active-HDL Interfaces Building VHPI Applications C Compilation Course 9.
9/2/ CS171 -Math & Computer Science Department at Emory University.
Using Microsoft Visual Studio 2005 Original by Suma Rao Revised by John G. McMahon ( 9/6/2008 )
Using Microsoft Visual Studio C++ Express 2005 Name: Dr Ju Wang Ashwin Belle Course Resource:
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
Information and Communication Technology Sayed Mahbub Hasan Amiri Dhaka Residential Model College Higher Secondary.
Using Advanced Options Lesson 14 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft Word 2013.
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
CS320n –Visual Programming More LabVIEW Foundations.
Using Visual Studio C++ Express Ron Gross A current copy of this can be found at or this direct linkhttp://tinyurl.com/2ucarothis.
Links take you to…  Different slides in your presentation  A different PowerPoint presentation  Any program - (Word can be used for example to complete.
1 How to Install OpenGL u Software running under Microsoft Windows makes extensive use of "dynamic link libraries." A dynamic link library (DLL) is a set.
Lab00-Getting Started with VC Launch VS 2005 Launch Visual Studio 2005 – Start > All Programs > Microsoft Visual Studio 2005 > Microsoft Visual.
Install a Windows Service Application Windows Development Fundamentals LESSON 3.2.
Lecture Set 2 Part A: Creating an Application with Visual Studio – Solutions, Projects, Files 8/10/ :35 PM.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Open project in Microsoft Visual Studio → build program in “Release” mode.
Creating a Web Site Creating a new Web site Defining and using folders Creating and editing Web pages Viewing pages in a Web browser.
Spell Checker web service (you build a web client that interacts with the service) The client uses a servlet class and a JSP page. The user passes information.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
DEVRY CIS 170 C I L AB 1 OF 7 G ETTING S TARTED Check this A+ tutorial guideline at
Development Environment Setup
Chapter 2: The Visual Studio .NET Development Environment
Getting Eclipse for C/C++ Development
Quick Start Guide for Visual Studio 2010
Lab 1 Introduction to C++.
1. Open Visual Studio 2008.
Lab 1 Introduction to C++.
Our Environment We will exercise on Microsoft Visual C++ v.6
Double click Microsoft Visual Studio 2010 on the Computer Desktop
Getting Eclipse for C/C++ Development
Running a Java Program using Blue Jay.
Presentation transcript:

Using Visual C++ and Pelles C -IDE & Compilers- www.tenouk.com, ©

Using VC++ (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, ©

Using VC++ 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, ©

Using VC++ Step: select Application Settings (or Next > button). www.tenouk.com, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ Step: Copy and paste the following C source code to the source file. #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\n", p); return 0; } Code sample in text 1 www.tenouk.com, ©

Using VC++ Now the C source file has source code in it. We are ready to build (compile and link) the project. www.tenouk.com, ©

Using VC++ Step: select Build menu > select Compile sub-menu. www.tenouk.com, ©

Using VC++ Optionally, we can directly build the solution (Build Solution sub-menu) 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ #include <stdio.h> int main(void) { int i, p; 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, ©

Using VC++ 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, ©

Using VC++ Step: next, try re-run the program and key-in another different inputs. #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); scanf("%2d%f%*d %[0123456789]", &i, &x, name); printf("i = %i, x = %f, name = %s\n", i, x, name); return 0; } 32 52.42E-1 Tiger 56789 0123 56a72 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, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ Step: click Application Settings or click Next > button. www.tenouk.com, ©

Using VC++ Step: select Empty project tick box > click Finish button. Left other settings as default. www.tenouk.com, ©

Using VC++ 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, ©

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

Using VC++ Step: Copy and paste the following C source code. #include <stdio.h> 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); return 0; } Code sample in text 4 www.tenouk.com, ©

Using VC++ 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, ©

Using VC++ 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, ©

Using VC++ Step: Build the program as done previously. Make sure there is no error. www.tenouk.com, ©

Using VC++ Step: run the program as done previously. www.tenouk.com, ©

Using VC++ The following shows a sample output. www.tenouk.com, ©

Using VC++ 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, ©

USING PELLES C www.tenouk.com, ©

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, ©

Using Pelles C www.tenouk.com, ©

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

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

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

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

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

Using Pelles C Step: copy and paste the following C source code into the source file. #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\n", p); return 0; } Code sample in text 5 www.tenouk.com, ©

Using Pelles C www.tenouk.com, ©

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, ©

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

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, ©

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, ©

End. Thank you www.tenouk.com, ©