1 editing a c program 01/16/15. 2 objective use linux to edit, compile and execute a c program
TRANSCRIPT
1
Editing a C Program
01/16/15
2
Objective
• Use Linux to edit, compile and execute a C program
3
Login and Password• Don’t lose it
• Keep password a secret
4
Steps to Run a C program
• Login into onyx
• Edit the program using vi or vim
• Compile the program with gcc
• Execute the program with a.out
• Logout out of onyx
5
What are two modes in vi?
• Command
• Insert
6
vim• I want to write a program whose output is:Martin Luther King said:
I have a dream.
• I will write a C program to do that.
• I will use the vim editor to create the program.
7
To Execute a Program
• vim prog.c– Edit the program– Save with :wq
• gcc prog.c– If there are errors, correct and recompile.
• a.out
8
Logout
• exit
• Right click on desk top
• Select “leave”
• Select “logout” button
• Important
9
vim Commands• a, i -- Get into insert mode• <esc> -- Get back to command mode• x -- delete a character• dd -- delete a line• p -- paste• u -- undo• :wq -- write and quit• :q! -- quit without saving.• arrow keys -- move around
10
More vim Commands• 3x -- Number makes command happen that many
times.• p - put (paste) • r – replace• G
• You should know the commands in the vimtutor, 1.1 to 4.1
11
More Linux
• Command Formatcommand -options arguments
• Commands to know:– ls, lpr, cp , rm, mv, – mkdir, mv(to a directory), cd, cd .., rmdir– man, more, cat– exit
12
Login from Remote Site
• You can get mobaxterm or other ssh software if you have a PC
• For Macs see me.
13
Engr 213 & 214
• Labs for Comp Sci.
14
Assignment
• See the website for assignment.• Do program 1 for next Friday, 1/23/15
15
Next Week
• Hardware, software and algorithms
• Getting Started in C Programming