1 / 13

CSE 20232 Lecture 2 – More Preliminaries

CSE 20232 Lecture 2 – More Preliminaries. Reading Assignments Linux, g++ & dropboxes Simple C/C++ Program (again) Edit, Compile, Test, Submit. Reading Assignments. Begin reading in Deitel … Week 1 Sections 1.2-1.4, 1.7-1.9, 1.13-1.17 Sections 2.1-2.4 Week 2 Sections 2.5-2.7,

holleb
Download Presentation

CSE 20232 Lecture 2 – More Preliminaries

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. CSE 20232Lecture 2 – More Preliminaries • Reading Assignments • Linux, g++ & dropboxes • Simple C/C++ Program (again) • Edit, Compile, Test, Submit

  2. Reading Assignments • Begin reading in Deitel … • Week 1 • Sections 1.2-1.4, 1.7-1.9, 1.13-1.17 • Sections 2.1-2.4 • Week 2 • Sections 2.5-2.7, • Appendices B, C, E.1-E.2

  3. UNIX/Linux Basics • Basic commands • ls list directory contents • cd change to another directory • mkdir, rmdir make or remove a directory (folder) • pwd displays current path • rm remove a file • mv move or rename a file • cp copy a file • less page through a text file • man display manual page on command

  4. UNIX/Linux Basics • Basic commands • !! “bang bang” execute last command • !x execute last command x* • | pipe output of one command into another • history show list of previous commands • ln - s create symbolic link • < take input from file • > send output to file • >> append output to file

  5. Simple C++ Program Structure • Comment block • Filename, author, date, purpose, description, … • Preprocessor directives #include … • Using statements using namespace std; • Main function int main () { Declarations Statements return 0; }

  6. Simple C++ Program (helloWorld.cpp) // file: helloWorld.cpp // author: J H Stewman // date: 8/22/2006 // purpose: CSE 20232 – Notre Dame – demo // description: // this shows the world we care #include <iostream> using namespace std; int main( ) { cout << “Hello World!” << endl; return 0; }

  7. Simple C++ Program (addTwo.cpp) // file: addTwo.cpp // author: J H Stewman // date: 8/22/2006 // purpose: CSE 20232 – Notre Dame – demo // description: ages you by two years #include <iostream> using namespace std; int main( ) { int age; cout << “Hello, what is your age? ”; cin >> age; cout << “In two years you will be ” << age + 2 << endl; return 0; }

  8. Simple Program using Integers to Sum two Vectors #include <iostream> using namespace std; int main( ) { int x1, y1, x2, y2, rx, ry; // v1, v2, and result // prompt user and acquire inputs cout << "Enter x and y components of vector (v1): "; cin >> x1 >> y1; cout << "Enter x and y components of vector (v2): "; cin >> x2 >> y2; // compute vector sum and display result rx = x1 + x2; ry = y1 + y2; cout << "(v1 + v2) is the vector (" << rx << ',' << ry << ')' << endl; return 0; }

  9. UNIX/Linux Basics • Creating a symbolic link • ln –s /afs/nd.edu/coursefa.06/cse/cse20232.01/dropbox/jstewman mydrop • Compiling • Compile source to object file • g++ -g -c helloWorld.cpp • Link object file and create executable • g++ -o helloWorld helloWorld.o • Do it all in one step • g++ -g -o helloWorld helloWorld.cpp

  10. UNIX/Linux Editors • Console Editors • vi Commands • i – insert mode • a – append mode • r – replace mode • x – delete character • dd – delete line • <esc> - exit mode • :! – exit with no change • ZZ – exit and save file • pico • GUI Editors • nedit – start from command line – nedit pgm.cpp & • emacs – start from command line – emacs pgm.cpp & • & runs program in background so console isn’t locked

  11. Debuggers • Console Debuggers • gdb • Commands: help, run, print, break, cont, list, … • GUI Debuggers • DDD • Kdbg • Start both from Linux CDE menu

  12. Run / Test / Submit • Run your program from a Terminal or xterm by typing … • ./helloWorld • If it does not work correctly, it has a “bug,” so … • Make changes to source, recompile, link, and test again • This is called “testing and debugging” • To submit your program to your dropbox … • if you created a symbolic link (mydropbox) • cp hw1_1.cpp mydropbox/hw1 • otherwise ... • cp hw1_1.cpp /afs/nd.edu/coursefa.06/cse/cse20232.01/dropbox/your_afsid/hw1

  13. Demo • Go to Linux box and show use of … • Commands • Creation of symbolic link • Editors • GNU g++ Compiler/Linker • Testing & debugging • NOTE: sample programs will be placed on the class web site

More Related