Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Reading Assignments Linux, g++ & dropboxes Simple C/C++ Program (again) Edit, Compile, Test, Submit CSE 20232 Lecture 2 – More Preliminaries.

Similar presentations


Presentation on theme: "1 Reading Assignments Linux, g++ & dropboxes Simple C/C++ Program (again) Edit, Compile, Test, Submit CSE 20232 Lecture 2 – More Preliminaries."— Presentation transcript:

1 1 Reading Assignments Linux, g++ & dropboxes Simple C/C++ Program (again) Edit, Compile, Test, Submit CSE Lecture 2 – More Preliminaries

2 2 Reading Assignments Begin reading in Deitel … Week 1 Sections , , Sections Week 2 Sections , Appendices B, C, E.1-E.2

3 3 UNIX/Linux Basics Basic commands ls list directory contents cdchange to another directory mkdir, rmdirmake or remove a directory (folder) pwddisplays current path rmremove a file mvmove or rename a file cpcopy a file lesspage through a text file mandisplay manual page on command

4 4 UNIX/Linux Basics Basic commands !! “bang bang” execute last command !xexecute last command x* |pipe output of one command into another historyshow list of previous commands ln - screate symbolic link send output to file >>append output to file

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

7 7 Simple C++ Program (addTwo.cpp) // file: addTwo.cpp // author: J H Stewman // date: 8/22/2006 // purpose: CSE – Notre Dame – demo // description: ages you by two years #include 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 8 Simple Program using Integers to Sum two Vectors #include 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 9 UNIX/Linux Basics Creating a symbolic link ln –s /afs/nd.edu/coursefa.06/cse/cse /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 10 UNIX/Linux Editors Console Editors vi Commands  i – insert mode  a – append mode  r – replace mode  x – delete character  dd – delete line  - 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 11 Debuggers Console Debuggers gdb Commands: help, run, print, break, cont, list, … GUI Debuggers DDD Kdbg Start both from Linux CDE menu

12 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/cse /dropbox/your_afsid/hw1

13 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


Download ppt "1 Reading Assignments Linux, g++ & dropboxes Simple C/C++ Program (again) Edit, Compile, Test, Submit CSE 20232 Lecture 2 – More Preliminaries."

Similar presentations


Ads by Google