Title: CS 261 Recitation 1
1CS 261 Recitation 1
Oregon State University School of Electrical
Engineering and Computer Science
2Outline
- Using Secure Shell Clients
- Basic commands
- Text Editors
- The GCC
- Some Examples
- C IDE in Windows
3Using Secure Shell Clients
- Open Secure Shell Client (for Windows PC)
- Open Terminal type ltusernamegt_at_lthost namegt
(for Mac)
4Using Secure Shell Clients
- List of available servers
- flip.engr.oregonstate.edu
- flop.engr.oregonstate.edu off-campus
- shell.onid.oregonstate.edu
- and more (see http//eecs.oregonstate.edu/it/)
5Using Secure Shell Clients
Transferring your files to UNIX account
6Using Secure Shell Clients
- Other Secure shell clients available
- Remote connect PuTTY
- http//www.chiark.greenend.org.uk/sgtatham/putty
/ - File Manager WinSCP
- http//winscp.net/eng/index.php
7Basic commands
- pwd
- Present working directory
- ls/dir
- list files and directories in current directory
- cd
- Change directory
- cd ..
- move to parent directory
- mkdir
- make new directory
- cp
- copy ltsrcFileNamegt ltdesFileNamegt
- rm
- remove file
- rmdir
- remove folder
- cat
- show file content
- exit
8Text Editors
- Emacs
- To start emacs ltfilenamegt
- Common commands
- Ctrl X Ctrl S Save
- Ctrl X Ctrl C Exit
- More information http//lowfatlinux.com/linux-edi
tor-emacs.html - Vim
- To start vim ltfilenamegt
- 3 modes for text editing
- Insert (i)
- Replace (r / R)
- Browse (Esc)
- To save - w
- To quit - q
- More information http//vimdoc.sourceforge.net/h
tmldoc/usr_toc.html
9Task 1
- Use any Secure Shell Client to connect
flip.engr.oregonstate.edu - Create a folder named CS261
- Change working directory to CS261
- Create a folder named Rec1
- Create a folder named Temp
- Remove folder Temp
- Change working directory to Rec1
- Use emacs or vim, create and file named info.txt
and input your name. - Use cat to show content of info.txt
- Copy info.txt to the CS261 folder
- Delete both info.txt files.
- (check your work with file transfer tool)
10The GCC
- The GNU Compiler Collection (usually shortened to
GCC) is a command line compiler system produced
by the GNU Project, supporting various
programming languages (includes C, C). - Compiling with GCC
- gcc ltlist of optionsgt sourcefile.c
- e.g. gcc -Wall ansi -o test test.c
- Output
- Compiling the code converts it into object files
(.o) - Linking the code uses the information from the
object code to build executable. -
11Using the GCC compiler (cont.)
- Common options
- -Wall Show all warnings
- -ansi Using standardized version of ANSI C
- -o ltfilenamegt Name the output file
- -c Compile but dont link
12Using the GCC compiler (cont.)
- Compile multiple files
- To stop the process till compilation step
- gcc c code1.c code2.c code3.c
- To link the individual .o files to generate the
executable - gcc o executor code1.o code2.o code3.o
- The same can be done in a single step
- gcc o executor code1.c code2.c code3.c
13Examples
- Example 1 Hello World
- Example 2 Hello World with Header file
- Example 3 Swap
14C IDE in Windows, Mac OS x
- Codeblocks is a free C IDE built to meet the
most demanding needs of its users. It is designed
to be very extensible and fully configurable. - To download, go to http//www.codeblocks.org/down
loads/5
15Programming C using CodeBlocks
- Open CodeBlocks
- File gt New gt Project gt Empty Project gt Go
16Programming C using CodeBlocks (Cont.)
- Enter Project Title, Folder, Project
filename, and Resulting fileName
17Programming C using CodeBlocks (Cont.)
- Select GNU GCC Compiler
- Check the two checkboxes if you want to create
debug and release configuration.
18Programming C using CodeBlocks (Cont.)
- Add source file to this project File gt New gt
File gt C/C Source gt Choose C as the programming
language. After that, enter file name with full
path, remember to turn on Add file to active
project - The procedure is similar when adding a header
file.
19Programming C using CodeBlocks (Cont.)
- To build the project, press Ctrl F9
- To run the project, press Ctrl F10
20NOTE
- You can use any program to develop and test your
C application before submitting. However, UNIX is
the environment in which the program will be
graded. So make sure your program will compile
and run without errors or warnings when using GCC.