Presentation is loading. Please wait.

Presentation is loading. Please wait.

First Day in Lab Making a C++ program

Similar presentations


Presentation on theme: "First Day in Lab Making a C++ program"— Presentation transcript:

1 First Day in Lab Making a C++ program
CS-1511 Computer Science I

2 Desktop Click the Apps4U icon

3 Apps4U Loading Screen

4 Scroll down to Putty

5 Launch Putty

6 Logging on to Bulldog bulldog.d.umn.edu putty

7 Enter bulldog.d.umn.edu Click Open

8 Click Yes

9 Type in your UMD account name, hit Enter,
Then type your password, hit Enter Note: none of the password characters you type will display on the screen, however, they are being entered so keep going. You know you are on unix when you see bulldog~% or a prompt ending in % bulldog~% Put the mouse aside. You won’t be needing it for a while.

10 Creating a C++ File This is hello.cpp Type your C++ instructions here
bulldog~% nano hello.cpp bulldog~% When finished hit Ctrl-x to leave

11 Using nano Log into your unix account. You know you are there when you see the % prompt. % means “I am ready for your first command” We use the nano text editor to create files. The first file we create we will call hello.cpp. After we have created our file we will leave the nano editor, saving the file we made. Note: Another program similar to nano is called pico. Both work exactly the same way.

12 Create the file hello.cpp using the nano text editor nano hello.cpp
bulldog~% nano hello.cpp

13 You are in the nano editor and the file you are creating is hello.cpp

14 Type in the code you see here

15 When you are finished hold down the Ctrl key and hit X

16 If you want to save your changes type Y
If you want the file to be called hello.cpp hit Enter

17 The compilation process
hello.cpp a.out g++ hello.cpp g++ a C++ compiler

18 Compiling Your C++ Program
After we have created our file we will leave the nano editor, saving the file we made. That puts us back in unix. You will now see another bulldog~% prompt. This means “I am ready for your next command” Our second command will compile the C++ file we created (hello.cpp) using the g++ compiler. To compile our program type g++ hello.cpp This makes an executable version called a.out At the next unix prompt we can run a.out by typing ./a.out The results will be displayed.

19 Type g++ hello.cpp to compile your program
bulldog~% nano hello.cpp bulldog~% g++ hello.cpp You are now back in unix Type g++ hello.cpp to compile your program

20 bulldog~% nano hello.cpp bulldog~% g++ hello.cpp bulldog~% a.out
a.out: Command not found bulldog~% ./a.out Hello World!bulldog~% To run your program type ./a.out You should see the results

21 Go back into nano and insert a \n (new line) character
Go back into nano and insert a \n (new line) character. Then save it, recompile, and run again

22 Now it runs and produces a new line
bulldog~% nano hello.cpp bulldog~% g++ hello.cpp bulldog~% a.out aout: command not found bulldog~% ./a.out Hello World!bulldog~% nano hello.cpp Hello World! bulldog~% Now it runs and produces a new line

23 bulldog~% nano hello.cpp
bulldog~% g++ hello.cpp bulldog~% a.out aout: command not found bulldog~% ./a.out Hello World!bulldog~% nano hello.cpp Hello World! bulldog~% logout Leave by logging out logout

24 Unix Commands Commands you know nano file1.cpp opens the nano editor with file1.cpp g++ file1.cpp compiles file1.cpp using the g++ compiler logout logs you out of the system

25 Unix Commands Other unix commands you might want to try ls lists your files pwd print working directory (tells you where you are) cp file1.cpp file2.cpp copies file1.cpp onto a new file called file2.cpp ! Runs the last command that begins with a letter

26 Logout Screen Don’t forget to Logoff


Download ppt "First Day in Lab Making a C++ program"

Similar presentations


Ads by Google