Tutorial 1 Writing Your First C++ Program CSC1110C Introduction to Computer Programming By Paul Pun Acknowledgement: Special thanks to Dr. Michael Fung and Szeto for sharing their well-prepared PowerPoint
Outline What is an IDE? Microsoft Visual Studio 2003 Dev-C++ Getting familiar with MS Visual Studio Writing your first C++ program Compilation Execution Common Errors
What is an IDE? Integrated Development Environment Usually includes: Editor – where you type in your code Compiler – translates C++ code to executable format Debugger – helps you to locate program errors e.g. Microsoft Visual Studio, Dev-C++
Microsoft Visual Studio Includes Visual C++/C#/Basic…etc. We will only use Visual C++ MS VS2003 available at EE department You can download from Check your EE accounts for login ID and password
Dev-C++ Free download at Complete IDE with editor, compiler and debugger Please refer to online documentation for installation and use of this product
Your first program - Helloworld //This program do nothing except saying hello #include using namespace std; int main() { cout << "Hello, world!" << endl; return 0; }
Launching Visual Studio 2003
Overview Debug and build output View classes, source files here Manage projects, and edit source file Click to open new Project or … …Click here
Creating C/C++ Win32 Console project
Application Settings
Adding a New Item – Method 1
Adding a New Item – Method 2 Click to activate Solution Explorer
Add New C/C++ Source File Item
Type in Program HelloWorld.cpp
Start Compile/ Build/ Debug [F5]
Start Without Debugging [Ctrl-F5]
Compile/ Build Successful
Hello World! [Ctrl-F5] Press any key to close console window
Common Errors (1) 1) This dialog indicate errors in our code 2) Check here for error and line number 3) Missing semicolon!
Common Errors (2) 2) Missing double quote! 1) Check here for error and line number