lab2 - ME 218 LAB: PROGRAMMING REVIEW 1 1 ME 218 Lab: C/C+...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ME 218 LAB: PROGRAMMING REVIEW 1 1 ME 218 Lab: C/C++ Review Now that we have refreshed our fundamental MATLAB skills, it is time to review your C/C++ programming skills as well. Before we write our first program, let‟s take this opportunity to review the programming environment : the editor , compiler , and linker . 1.1 PROGRAMMING ENVIRONMENTS This section contains instructions for writing programs using CodeWarrior or Visual Studio. You may use another package if you choose, BUT TA‟s have focused their attention on Visual Studio and CodeWarrior support. You may also use either C or C++ to complete any program assigned in this course. There are many packages available that allow you to edit your program, compile it, and link to other necessary files all using the same application or programming environment . Visual Studio 6.0 and CodeWarrior 6.0 are two good examples. You do not need to go out and purchase more software . The Mechanical Engineering Learning Resource Center (MELRC) has both of these applications and many more available for your use at http://www.me.utexas.edu/~melrc/appserver.php . These software packages are also installed on the computers in ETC 3.112 and in the MELRC undergraduate computer lab. Both of these applications contain lots of functionality for developing complex programs containing multiple files and advance features. Feel free to explore all the features of these programs, but you will not need much (if any) of the advanced functionality to complete the assigned programs in this course. The next two sections review how to create simple programs in Visual Studio and Code Warrior. 1.1.1 Creating a program using Visual Studio 6.0 After opening Visual Studio 6.0, go to: File → New…→Project Select Win32 Console Application Name Project (ex. “lab2_pryor”) Select Location to save project Click OK or Next Select „An empty project‟ (the „hello world‟ app will contain stuff we don‟t need to worry about.) Click Finish Click OK to confirm settings
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ME 218 LAB: PROGRAMMING REVIEW 2 Click on the FileView Tab (bottom left of window) Select „Source Files‟ Folder Project Add to Project New… Select C++ Source File (C++ is backwards compatible so C syntax is valid in C++ Source files) Name the file „main.c‟ OR „main.cpp‟ (C or C++ respectively) Using the editor, type either of the following programs depending on your C/C++ preference. /* C starter file */ #include “stdio.h” main ( ) { printf( “Hello World. \ n”); } // C++ starter file #include <iostream.h> using namespace std; void main( ) { cout << “Hello World.” << endl; return; } (NOTE: Only the program on the left will execute if you created a main.c file. If you create a main.cpp file, both programs will compile, but the one on the left will return a warning until you add „void‟ and „return.‟) To compile the program, press Ctrl+F7 . Any errors will be reported in a window at the bottom of the screen. Once the program has compiled successfully, press
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2011 for the course ME 218 taught by Professor Unknown during the Fall '08 term at University of Texas at Austin.

Page1 / 8

lab2 - ME 218 LAB: PROGRAMMING REVIEW 1 1 ME 218 Lab: C/C+...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online