1 / 36

Getting Started with C++

Getting Started with C++. Part 2. Getting Started on Linux. Today we will look at Linux. See how to copy files between Windows and Linux Compile and run the “Hello, World” program. Try out a very simple editor. hello.cpp.

jeneil
Download Presentation

Getting Started with C++

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Getting Started with C++ Part 2

  2. Getting Started on Linux • Today we will look at Linux. • See how to copy files between Windows and Linux • Compile and run the “Hello, World” program. • Try out a very simple editor.

  3. hello.cpp • If you don’t have hello.cpp from last class you can download it from the class web site: • http://www.cse.usf.edu/~turnerr/Object_Oriented_Design/Downloads/

  4. Downloads Area • Download the file without the .txt extension. • Save it as hello.cpp

  5. Downloading with Internet Explorer Right click on the file name. Select “Save Target As …”

  6. Save to the Desktop Be sure to select “All Files”

  7. About Circe • All USF students have access to a Linux system known as Circe. • Try logging in with your USF NetID. • If unsuccessful, you can set up an account on line. • (Details follow.)

  8. Connecting to Circe • Use an SSH terminal client program to connect to Circe. • Recommended client program is PuTTY • Can download from http://it.usf.edu/standards/security/tools • You will also need an SSH file transfer program. • WinSCP

  9. USF IT Software Page

  10. Connecting with PuTTY

  11. Using Circe

  12. Create a Test Directory

  13. Copying a File to Circe • Use an SSH file transfer program to copy the C++ source file to an empty directory on Circe. • WinSCP • FSecure Shell • Create a new directory if necessary.

  14. Connecting to Circe with WinSCP

  15. Connected to Circe

  16. Pick a Directory Pick an empty directory to work in. Or create a new one.

  17. Drag source file into remote directory window Copy Source File

  18. Open a Terminal Window

  19. Connect to Circe and cd to Test Directory.

  20. Compile the Program

  21. Run It

  22. Creating a Source File on Circe Delete existing files. We will start from scratch.

  23. Creating a Source File on Circe

  24. Creating a Source File on Circe Press Ctrl-o to write out the file.

  25. Creating a Source File on Circe

  26. Creating a Source File on Circe Press Ctrl-x to exit.

  27. Exit from the Editor

  28. View the Source File

  29. Compile and Run

  30. The Manipulator endl #include <iostream> int main( void ) { std::cout << "Hello, World!"; std::cout << std::endl; return 0; } std::endl is not a character like'\n' It is an instruction to cout to start a new line. Referred to as a manipulator.

  31. Multiple outputs with cout #include <iostream> int main( void ) { std::cout << "Hello, World!" << std::endl; std::cin.get(); return 0; } << operators can be cascaded as many times as you wish.

  32. Input from the Keyboard #include <iostream> int main( void ) { int a; int b; std::cout << "Enter two integers to compute their sum:" << std::endl; std::cin >> a; std::cin >> b; std::cout << "The sum of " << a << " and " << b << " is "; std::cout << a + b << std::endl; return 0; }

  33. Input from the Keyboard

  34. Avoiding all those "std::"s #include <iostream> using namespace std; int main( void ) { int a; int b; cout << "Enter two integers to computer their sum:" << endl; cin >> a; cin >> b; cout << "The sum of " << a << " and " << b << " is "; cout << a + b << endl; return 0; }

  35. Being More Selective #include <iostream> using std::cin; using std::cout; using std::endl; int main( void ) { int a; int b; cout << "Enter two integers to computer their sum:" << endl; cin >> a; cin >> b; cout << "The sum of " << a << " and " << b << " is "; cout << a + b << endl; ... return 0; } This is generally considered better practice.

  36. Assignment Before next class • Be sure you can connect to Circe and log in using your USF NetID. • Do today’s examples for yourself if you didn’t do them in class. • Read Chapters 1 and 2. End of Presentation

More Related