COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez...

14
COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez [email protected] http://cise.ufl.edu/~djrg/ https://ufcprog2015.wordpress.com /

Transcript of COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez...

Page 1: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

COP 3275 COMPUTER PROGRAMMING USING CInstructor: Diego Rivera-Gutierrez

[email protected] http://cise.ufl.edu/~djrg/

https://ufcprog2015.wordpress.com/

Page 2: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

LET’S BACKTRACK A BIT!

• Did you guys register for a CISE account? • If not, do so soon! http://register.cise.ufl.edu/

• Why do we need an account?• All homework projects are expected to work on the

CISE Linux machines! • So, if your program doesn’t run, “But it works on my

laptop/computer” will not be an acceptable excuse!

Page 3: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

SETTING UP YOUR PROGRAMMING ENVIRONMENT

Page 4: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

SO HOW DO I ACCESS A COMPUTER TO TEST MY PROJECT?

• Multiple ways! (Once you have registered for an account)

1. You can always go to one of the CISE computer labs and login to your account there: https://www.cise.ufl.edu/help/access

2. You can do remote access to one of the servers.

Page 5: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

QUICK POLL

Page 6: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

CONNECTING TO A REMOTE TERMINAL

• Windows• Putty is your best option

• Mac OS• From a terminal you can always do SSH. To do so:

• Open a Terminal• Type: ssh <yourusername>@thunder.cise.ufl.edu• For example: [email protected]

Page 7: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

UPLOADING FILES TO MY ACCOUNT

• Windows• WinSCP is your best option

• Mac OS• Any SFTP client will do• Options:

• Cyberduck• FileZilla

Page 8: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

I’M IN A REMOTE TERMINAL… NOW

WHAT?• So you should see something to the effect of:

• The first word (thunder/storm) tells you which server• thunder.cise.ufl.edu and storm.cise.ufl.edu are both

available to you

• The number (22/25) is a “command number” and is pretty irrelevant

• What should I do next?

thunder:22%

storm:25%

Page 9: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

RELEVANT COMMANDS• A list of useful commands is here: http://

www.computerhope.com/unix.htm

Command Function

man <command>

Provide manual for the command <command>

cd <directory> Change current directory/folder to <directory>

ls List contents of current directory

pwd Print working directory

mkdir <name> Make a new directory with the name <name>

cp <a> <b> Copy file <a> to location <b>

rm <file> Remove/Delete the file with name <file>

mv <a> <b> Move/Rename file <a> to location/name <b>

nano Open a file editor named nano(also known as pico)

nano <file> Open <file> with nano

cat <file> Outputs the contents of file to the terminal

Page 10: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

BY FAR THE COMMANDS YOU WILL USE THE

MOST

Compiling commands Function

gcc <file>.c Compile the C program file with name <file>.c, use the generic output name a.out

gcc <file>.c –o <file>.out

Compile the C program file with name <file>.c, use the output name <file>.out

• We will discuss these two in more detail on Friday (gcc compiler)

• Now… what does <file>.c looks like? (AKA what did I get myself into by taking this class?)

Page 11: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

LET’S WRITE A SIMPLE PROGRAM!

Notice: I’ll be using Notepad++ and pico/nano. You are free to use any IDE of your choosing, under two conditions:1) You will have to figure out how to use them on your own

(Neither me, nor Rahul the TA will be able to help you if you use an IDE we are not familiar with)

2) Your projects need to work correctly on the CISE servers using the compile lines we will provide.

Page 12: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

THE HELLO WORLD PROGRAM

#include <stdio.h> int main(void) { printf("Hello World!"); return 0;}

Page 13: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

THE EVEN BETTER “HELLO WORLD”

PROGRAM

#include <stdio.h> int main(void) { printf("Hello World!\n"); return 0;}

Page 14: COP 3275 COMPUTER PROGRAMMING USING C Instructor: Diego Rivera-Gutierrez djrg@cise.ufl.edudjrg@cise.ufl.edu djrg/djrg

POTENTIAL CONTENT FOR REST OF THE

CLASS• Other escaped characters (\n,\\,\”, \t, etc)

• Data types: char, int, float.

• Variable declarations.

• Formatted printf